User:Louis GCR/sandbox

Sensor & Actuator Board Version 3

Purpose
BBAUV Sensor and Actuator Board is a 7cm radius semi-circular board that fits onto the backplane. The main job of the SA board is to get sensor data from the board and also to control various actuators that the submarine carries. 1 major change is the inclusion of the MCU embedded onto the board, reducing the need for a Atmega2560 MCU and a shield for the sensors. Another change is the removal of controlling the submarine thrusters. Lastly the communication of the system changed from serial to using CAN bus, but serial is kept as a back up/ debugging tool.

Brains:
 * 1) Atmel2560

List of Sensors: List of Actuators: Communication:
 * 1) External Pressure
 * 2) Internal Pressure
 * 3) Temperature & Humidity
 * 1) LED Lights
 * 2) Festo Manipulators
 * 1) CAN network
 * 2) Serial as backup

Micro Controller Unit (MCU)
The MCU is Atmel2560, and is boot loaded with Arduino software. The connection for the MCU can be referred to on the schematics.

To bootload the MCU:
if you are using another MCU, use a different bootloader and flags setting  Tada it should be bootloaded, try to upload code if not repeat from first step
 * 1) Ensure proper connection of the SPI programming pins and the MCU (Under SPI Boot Loading Pin) & (ATMEGA2560)
 * 2) Ensure that the reset line is pull to 5v (Reset button Reset indication)
 * 3) Download & Launch Atmel Studio in Windows
 * 4) Install drivers if needed
 * 5) Connect the SPI programmer to board and click read. The device signature should be
 * 6) Set Flags to be
 * 7) Extend: 0xFD
 * 8) High: 0xD8
 * 9) Low: FF
 * 10) Use this file as the bootloader for ATMEGA2560 C:\Program Files (x86)\Arduino\hardware\arduino\bootloaders\stk500v2\stk500boot_v2_mega2560.hex it should be there unless you install Arduino in a different folder

To upload firmware into the MCU:

 * 1) To upload firmware into the MCU, connect the the FTDI up to the board,(see schematics)
 * 2) Go to the arduino IDE and upload code based on the correct board and port
 * 3) Code should be able to uploaded through the backplane


 * 1) Troubleshooting if unable to upload code
 * 2) Check the DTR capacitor to see if correct value
 * 3) Probe the DTR line, it should be high and when programming switch between high and low.
 * 4) If lines remains low all the time, you need a higher pull up resistor as low means it keeps resetting the MCU and therefore the program will time out.

External Pressure:
External pressure is measured using the depth sensor, the main idea is that the as pressure changes, the resistance of the pressure sensor changes. By measuring the voltage, we can gauge what is the pressure outside.

12V is given to the external pressure sensor and connected in series across a 250 ohm resistor. The voltage across this resistor can be fed to 1 of the 2 ADS. Sense2 goes to main ADS while Sense3 goes to back up ADS

The ADS is ADS1116 16 bits 806 samples per second. It uses I2C to send data to the MCU. Since I2C devices uses an addressing system, make sure the address is different for both the ADSs 0B1001001 while the slave ADS address is 0B1001000.

Internal Pressure:
The internal pressure sensor is using MPXH6250A6U & works the similarly as the external pressure sensor, except it sends it only to the main ADS and to channel 1.

Temperature & Humidity
The temperature & humidity sensor uses HIH6131, it does it's own calculation for temperature and humidity and sends it through via I2C.

LED Indicators
LED transistor are powered using 12V, they colours of the LEDs are controlled using PWM. The power transistors are IRF7910PBF, and 3 transistors are needed for all 3 colours. 12V is supplied to the LEDs and when the transistors are high, they allow current to sink to ground, turning the LED on. Therefore only 4 wires are needed for 3 colours, 12v shared among 3 colours and individual groups for the LEDs.

Actuators
The actuators uses a darlington array, ULN2803ADW. The array are just switches and turns on when the GPIO is high allowing 24v to flow to the array and turning on the actuators.