Project Objective: Develop an open source AIS Alarm that alerts sailors that a new marine vessel with AIS is within range
Now that there is a working microcontroller that runs at the right clock speed and blinks a LED it is worthwhile to outline the firmware.
/* * Outline of dAISy Alarm Prototype Code */ void main(){ initialize Clocks{ 8 MHz MCLK, SMCLK 32 kHz ACLK } initialize GPIO{ LED alarm Beeper alarm Serial RX Serial TX LED power } initialize Timers{ count milliSeconds } initialize UART{ 38400 baud } initialize Ring Buffer{ 16 messages of 120 bytes } for(;;){ if display_button pushed{ send all messages in buffer to UART TX } if reset_tracking_button pushed{ clear ring buffer initialize ring buffer turn off beeper alarm turn off LED alarm } if (beeping == true) & (milliSeconds - startBeeping) > BeepLength){ // beeps and LED toggle toggle GPIO LED alarm toggle GPIO Beeper alarm } // manage incoming NMEA characters if (UART RX has character){ store character in temporary buffer } // end of NMEA sentence if last character read is '\n' { store temporary buffer in the ring buffer clear temporary buffer start beeping start flashing the LED } }
If only writing real code were this easy.
It did flag something that should have put in the project description / specifications however. The ring buffer is assumed to hold 16 incoming AIS NMEA messages. The messages are less than 100 characters normally but the code will allow up to 120 characters to give some headroom. Note that 16 messages of 120 characters is approximately 2k bytes. The MSP430FR2111 only has 4k bytes of FRAM and that must also hold the program code. In a pinch the number of messages could be reduced to 8. In any event, the number of messages needs to be confirmed before the final design is started so if necessary a larger microcontroller can be substituted.
Past Posts from this Project:
AIS Alarm - Prototype Hardware
References and Links:
WEGMATT LLC - dAISy AIS Receiver - low cost AIS receiver
Texas Instruments MSP430FR2xx FRAM Microcontrollers - Post No. 4
http://www.ti.com/product/MSP430FR2111?keyMatch=msp430fr2111&tisearch=Search-EN