Name: U12.rawAISample(channel0PGAMUX = 8, channel1PGAMUX = 9, channel2PGAMUX = 10, channel3PGAMUX = 11, UpdateIO = False, LEDState = True, IO3toIO0States = 0, EchoValue = 0) Args: chan
(self, channel0PGAMUX = 8, channel1PGAMUX = 9, channel2PGAMUX = 10, channel3PGAMUX = 11, UpdateIO = False, LEDState = True, IO3toIO0States = 0, EchoValue = 0)
| 588 | # Begin Section 5 Functions |
| 589 | |
| 590 | def rawAISample(self, channel0PGAMUX = 8, channel1PGAMUX = 9, channel2PGAMUX = 10, channel3PGAMUX = 11, UpdateIO = False, LEDState = True, IO3toIO0States = 0, EchoValue = 0): |
| 591 | """ |
| 592 | Name: U12.rawAISample(channel0PGAMUX = 8, channel1PGAMUX = 9, |
| 593 | channel2PGAMUX = 10, channel3PGAMUX = 11, |
| 594 | UpdateIO = False, LEDState = True, |
| 595 | IO3toIO0States = 0, EchoValue = 0) |
| 596 | |
| 597 | Args: channel0PGAMUX, A byte that contains channel0 information |
| 598 | channel1PGAMUX, A byte that contains channel1 information |
| 599 | channel2PGAMUX, A byte that contains channel2 information |
| 600 | channel3PGAMUX, A byte that contains channel3 information |
| 601 | IO3toIO0States, A byte that represents the states of IO0 to IO3 |
| 602 | UpdateIO, If true, set IO0 to IO 3 to match IO3toIO0States |
| 603 | LEDState, Turns the status LED on or off. |
| 604 | EchoValue, Sometimes, you want what you put in. |
| 605 | |
| 606 | Desc: Collects readings from 4 analog inputs. It can also toggle the |
| 607 | status LED and update the state of the IOs. See Section 5.1 of |
| 608 | the User's Guide. |
| 609 | |
| 610 | By default it will read AI0-3 (single-ended). |
| 611 | |
| 612 | Returns: A dictionary with the following keys: |
| 613 | PGAOvervoltage, A bool representing if the U12 detected overvoltage |
| 614 | IO3toIO0States, a BitField representing the state of IO0 to IO3 |
| 615 | Channel0-3, the analog voltage for the channel |
| 616 | EchoValue, a repeat of the value passed in. |
| 617 | |
| 618 | Example: |
| 619 | >>> import u12 |
| 620 | >>> d = u12.U12() |
| 621 | >>> d.rawAISample() |
| 622 | { |
| 623 | 'IO3toIO0States': |
| 624 | <BitField object: [ IO3 = Low (0), IO2 = Low (0), |
| 625 | IO1 = Low (0), IO0 = Low (0) ] >, |
| 626 | 'Channel0': 1.46484375, |
| 627 | 'Channel1': 1.4501953125, |
| 628 | 'Channel2': 1.4599609375, |
| 629 | 'Channel3': 1.4306640625, |
| 630 | 'PGAOvervoltage': False, |
| 631 | 'EchoValue': 0 |
| 632 | } |
| 633 | |
| 634 | """ |
| 635 | command = [ 0 ] * 8 |
| 636 | |
| 637 | # Bits 6-4: PGA for 1st Channel |
| 638 | # Bits 3-0: MUX command for 1st Channel |
| 639 | command[0] = int(channel0PGAMUX) |
| 640 | |
| 641 | tempNum = command[0] & 7 # 7 = 0b111 |
| 642 | channel0Number = tempNum if (command[0] & 0xf) > 7 else tempNum+8 |
| 643 | channel0Gain = (command[0] >> 4) & 7 # 7 = 0b111 |
| 644 | |
| 645 | command[1] = int(channel1PGAMUX) |
| 646 | |
| 647 | tempNum = command[1] & 7 # 7 = 0b111 |
no test coverage detected