Open richarthurs opened 6 years ago
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
Thanks for the clarification!
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.
This requires:
Step 1:
Create a new branch off richard_temp&filesys (this has stlm75.h which is an I2C example)
Create a new header and .c file (sun_sensor.h).
Using the multiplexer data sheet: https://ca.mouser.com/datasheet/2/609/ADG728_729-878514.pdf, and the information in https://github.com/SFUSatClub/obc-firmware/wiki/I2C, create the function to set a multiplexer's channel
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