SFUSatClub / obc-firmware

Firmware for our cubesat's On-Board Computer using the TMS570LS0432 and FreeRTOS v9
16 stars 3 forks source link

Sun Sensor Multiplexer Function #60

Open richarthurs opened 6 years ago

richarthurs commented 6 years ago

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:

  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 commented 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

richarthurs commented 6 years ago

Thanks for the clarification!