element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Frank Milburn's Blog AIS Alarm - Prototype Code Outline
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: fmilburn
  • Date Created: 30 Dec 2017 10:56 PM Date Created
  • Views 411 views
  • Likes 3 likes
  • Comments 0 comments
Related
Recommended

AIS Alarm - Prototype Code Outline

fmilburn
fmilburn
30 Dec 2017

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

AIS Alarm - The Process

AIS Alarm - Prototype Hardware

AIS Alarm - Timers and GPIO

 

References and Links:

WEGMATT LLC - dAISy AIS Receiver - low cost AIS receiver

Texas Instruments MSP430FR2xx FRAM Microcontrollers - Post No. 4

TI MSP430FR2111

http://www.ti.com/product/MSP430FR2111?keyMatch=msp430fr2111&tisearch=Search-EN

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube