Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sun Sensor Multiplexer Function #60

Open
richarthurs opened this issue May 4, 2018 · 2 comments
Open

Sun Sensor Multiplexer Function #60

richarthurs opened this issue May 4, 2018 · 2 comments

Comments

@richarthurs
Copy link
Contributor

richarthurs commented May 4, 2018

We have several sun sensors which are multiplexed to 4 ADCs. We have 16 sun sensors, and we need to get values from all of them.

  • each multiplexer switches 4 sensors into a single ADC (if I remember right)
  • ADCs are read in bulk (there are several channels on an ADC, we use 4 channels for the sun sensors, one for each multiplexer)
  • so we need to set all muxes to channel 0, read the ADCs, record the 4 values, set muxes to channel 1, read the ADCs for the next 4 values, and so on

This requires:

  1. a function to send a command to a particular multiplexer to set it to a particular channel
  2. a function to read an ADC (we have this in sfu_tasks.c, vADCRead)
  3. a function to loop through and set the multiplexers up, then read the ADC values (it will call the above two functions). This will read every sensor.

Step 1:

Step 2:

Don't worry about the ADC for now, we'll deal with it later.

Step 3:

Create the 3rd function. We will need some sort of look up table to map the multiplexer number and ADC channel to the sun sensor number. Start with dummy values. We need to be able to loop through this table and grab readings from each mux/ADC combination (each sensor)

Table example: we need to loop through this

Mux | ADC | Sun Sensor
0 | 12 | 0
0 | 13 | 1
0 | 14 | 2
0 | 15 | 3
1 | 12 | 4
1 | 13 | 5
1 | 14 | 6
1 | 15 | 7
2 | 12 | 8
2 | 13 | 9
2 | 14 | 10
2 | 15 | 11
3 | 12 | 12
3 | 13 | 13
3 | 14 | 14
3 | 15 | 15

@TobiNakamura
Copy link
Member

Although each mux has 8 inputs not all are used! The number of sun sensors per mux is dependent on the hardware configuration which can be anywhere from 4 to 6. Thus the need for a look-up table of the form:
Sun Sensor | Mux | Mux Pin | ADC
0 | 0 | 1 | 0
1 | 0 | 3 | 0
2 | 0 | 6 | 0
3 | 0 | 7 | 0
4 | 1 | 1 | 1
5 | 1 | 2 | 1
6 | 1 | 3 | 1
7 | 1 | 5 | 1
8 | 1 | 6 | 1
9 | 1 | 7 | 1
etc.

Note that a particular mux will always have the same ADC since that is not configurable in hardware.

x+ mux - address 0x4C
- output goes to PC/104 26B
x- mux - address 0x4D
- output goes to PC/104 24B
y+ mux - address 0x4E
- output goes to PC/104 23B
y- mux - address 0x4F
- output goes to PC/104 25B

@richarthurs
Copy link
Contributor Author

Thanks for the clarification!

liquiddandruff added a commit that referenced this issue Jun 10, 2018
Setup:
- OBC/RF board set 1 compiled with STX strobe in rfTxTestSequence().
- OBC/RF board set 2 compiled with SRX strobe in rfTxTestSequence().
- In UART prompt, enter on both sets: > task resume 10
- Set 1 sample output:
...
radio task (0x0)
S 0x3d
 < 0x0f
tx_underflowed:no tx_numbytes:0
S 0x3d
 < 0x0f
TX FIFO_BYTES_AVAILABLE: 0xf
S 0xbd
 < 0x00
RX FIFO_BYTES_AVAILABLE: 0x0
S 0x3d
 < 0x0f
62 Bytes Radio TX FIFO written
AFTER: tx_underflowed:no tx_numbytes:62
S 0x35
 < 0x02
STX strobed...
S 0x3d
 < 0x24
StatusByte: 0x24
radio task (0x0)
S 0x3d
 < 0x0f
tx_underflowed:no tx_numbytes:0
S 0x3d
 < 0x0f
TX FIFO_BYTES_AVAILABLE: 0xf
S 0xbd
 < 0x00
RX FIFO_BYTES_AVAILABLE: 0x0
S 0x3d
 < 0x0f
62 Bytes Radio TX FIFO written
AFTER: tx_underflowed:no tx_numbytes:62
S 0x35
 < 0x02
STX strobed...
S 0x3d
 < 0x24
StatusByte: 0x24
radio task (0x0)
S 0x3d
 < 0x0f
tx_underflowed:no tx_numbytes:0
S 0x3d
 < 0x0f
TX FIFO_BYTES_AVAILABLE: 0xf
S 0xbd
 < 0x00
RX FIFO_BYTES_AVAILABLE: 0x0
S 0x3d
 < 0x0f
62 Bytes Radio TX FIFO written
AFTER: tx_underflowed:no tx_numbytes:62
S 0x35
 < 0x02
STX strobed...
S 0x3d
 < 0x24
StatusByte: 0x24

- Set 2 sample output:
...
radio task (0x0)
S 0x3d
< 0x02
tx_underflowed:no tx_numbytes:62
S 0x3d
< 0x02
TX FIFO_BYTES_AVAILABLE: 0x2
S 0xbd
< 0x0f
RX FIFO_BYTES_AVAILABLE: 0xf
S 0x3d
< 0x02
Radio did not write
AFTER: tx_underflowed:no tx_numbytes:62
S 0x34
< 0x02
STX strobed...
S 0x3d
< 0x12
StatusByte: 0x12
RX Byte #0: 3e
RX Byte #1: 10
RX Byte #2: 02
RX Byte #3: 03
RX Byte #4: 04
RX Byte #5: 05
RX Byte #6: 06
RX Byte #7: 07
RX Byte #8: 08
RX Byte #9: 09
RX Byte #10: 0a
RX Byte #11: 0b
RX Byte #12: 0c
RX Byte #13: 0d
RX Byte #14: 0e
RX Byte #15: 0f
RX Byte #16: 10
RX Byte #17: 11
RX Byte #18: 12
RX Byte #19: 13
RX Byte #20: 14
RX Byte #21: 15
RX Byte #22: 16
RX Byte #23: 17
RX Byte #24: 18
RX Byte #25: 19
RX Byte #26: 1a
RX Byte #27: 1b
RX Byte #28: 1c
RX Byte #29: 1d
RX Byte #30: 1e
RX Byte #31: 1f
RX Byte #32: 20
RX Byte #33: 21
RX Byte #34: 22
RX Byte #35: 23
RX Byte #36: 24
RX Byte #37: 25
RX Byte #38: 26
RX Byte #39: 27
RX Byte #40: 28
RX Byte #41: 29
RX Byte #42: 2a
RX Byte #43: 2b
RX Byte #44: 2c
RX Byte #45: 2d
RX Byte #46: 2e
RX Byte #47: 2f
RX Byte #48: 30
RX Byte #49: 31
RX Byte #50: 32
RX Byte #51: 33
RX Byte #52: 34
RX Byte #53: 35
RX Byte #54: 36
RX Byte #55: 37
RX Byte #56: 38
RX Byte #57: 39
RX Byte #58: 3a
RX Byte #59: 3b
RX Byte #60: 3c
RX Byte #61: 3d
RX Byte #62: e8
RX Byte #63: ba

Misc:
- Fix calculation of fifo bytes in writeToTxFIFO.
- TODO: readFromRxFIFO changed to always queuering FIFO_RX; change to check only when needed.
- Create IS_STATE macro to check state easily.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants