Jump to content


Photo

My Maple Microcontroller


  • This topic is locked This topic is locked
260 replies to this topic

#1 Dugggg

Dugggg

    Major Contributor

  • Validated Members
  • 556 posts

Posted 30 March 2012 - 07:45 PM

I just purchased a low-cost microcontroller board to automate my RV.   A microcontroller is like a mini computer, which you can program to perform various tasks, such as:

1. Displaying battery voltage, current, amp-hours, and other measurements
2. Sounding an alarm if the fridge gets too warm
3. Retracting the awning if the wind gets too strong
4. Turning off the water pump in the event of a pipe leak

Microcontrollers constantly monitor sensors and take necessary action.  Many RVs already use a microcontroller in the form of the popular Tire Pressure Monitoring System---and some battery chargers also use a microcontroller.

However, with mine, I have complete control over all the parameters and actions.  The sky's the limit---within budget, of course.   I am notorious on this forum for my low-cost solutions, and my new microcontroller is no different.    His name is HAL---kind of like that big computer in the movie 2001: A Space Odyssey---but mine's the size of a credit card, and he only costs about thirty dollars.

He's programmable using my laptop, which happens to be running the Ubuntu Linux operating system---though most any Apple or Windows laptop will also work.   If you know how to program a computer, it's very similar.   HAL seems to understand a variant of the C programming language. He has a micro-SD card slot, which means he can store gobs of data.  He can communicate through a common USB cable when he's hooked to my laptop, but he'll do most of his "talking" using an $8 LCD display, which will arrive on Monday.   In the mean time, already on his first day on the job, he's managed to send voltage measurements---accurate to better than a millivolt---to my laptop.   Over the weekend, he'll learn how to tell time and write to an SD card.

HAL is of Arduino descent.   Arduino was founded in Italy in 2005 on the concept that microcontrollers should be easy to program, be Open Source, and any extra hardware should be easy to attach.   From those modest 8-bit beginnings, a group of students at MIT endowed it with 32 bit power, and the  Maple Project was born.  Then some enterprising folks at Olimex in Bulgaria took it a step further, adding the key features that made it suitable for RV use:  industrial grade components, flexible power supply, real time clock, and SD card.   The board has only been available for a few months now, so it will be quite fun to be on "the cutting edge" for a while.

Thanks go to Ned Pepper's Chaps for casually mentioning Arduino, and Roadwarrior for pointing out the new Olimexino.

Edited by Dugggg, 30 March 2012 - 07:57 PM.

Fulltime boondocker for ten years, exploring AZ and NM with Bosco the cat

#2 Desolation Roe

Desolation Roe

    Major Contributor

  • Validated Members
  • 1919 posts
  • SKP#:106407

Posted 30 March 2012 - 08:12 PM

I'm very interested where you go with this.

I seem to smell the fragrant aroma of a commercially available product at some point, even if its a very small limited edition and if so please position me at number one in the queue. If it never goes commercial, I would still really like to clone whatever you end up with.

Very exciting and well done!!

Geo

George, Karen and Bubbles
2008 Volvo 780, 535hp 1850lb/ft D-16 I-Shift, 3.42
2005 Mobile Suites 38RL3

2014 Ford Expedition Limited


#3 Roadwarrior

Roadwarrior

    Major Contributor

  • Validated Members
  • 1054 posts
  • SKP#:111625

Posted 30 March 2012 - 09:13 PM

I just purchased a low-cost microcontroller board to automate my RV.   A microcontroller is like a mini computer, which you can program to perform various tasks, such as:

1. Displaying battery voltage, current, amp-hours, and other measurements
2. Sounding an alarm if the fridge gets too warm
3. Retracting the awning if the wind gets too strong
4. Turning off the water pump in the event of a pipe leak

Microcontrollers constantly monitor sensors and take necessary action.  Many RVs already use a microcontroller in the form of the popular Tire Pressure Monitoring System---and some battery chargers also use a microcontroller.

However, with mine, I have complete control over all the parameters and actions.  The sky's the limit---within budget, of course.   I am notorious on this forum for my low-cost solutions, and my new microcontroller is no different.    His name is HAL---kind of like that big computer in the movie 2001: A Space Odyssey---but mine's the size of a credit card, and he only costs about thirty dollars.

He's programmable using my laptop, which happens to be running the Ubuntu Linux operating system---though most any Apple or Windows laptop will also work.   If you know how to program a computer, it's very similar.   HAL seems to understand a variant of the C programming language. He has a micro-SD card slot, which means he can store gobs of data.  He can communicate through a common USB cable when he's hooked to my laptop, but he'll do most of his "talking" using an $8 LCD display, which will arrive on Monday.   In the mean time, already on his first day on the job, he's managed to send voltage measurements---accurate to better than a millivolt---to my laptop.   Over the weekend, he'll learn how to tell time and write to an SD card.

HAL is of Arduino descent.   Arduino was founded in Italy in 2005 on the concept that microcontrollers should be easy to program, be Open Source, and any extra hardware should be easy to attach.   From those modest 8-bit beginnings, a group of students at MIT endowed it with 32 bit power, and the  Maple Project was born.  Then some enterprising folks at Olimex in Bulgaria took it a step further, adding the key features that made it suitable for RV use:  industrial grade components, flexible power supply, real time clock, and SD card.   The board has only been available for a few months now, so it will be quite fun to be on "the cutting edge" for a while.

Thanks go to Ned Pepper's Chaps for casually mentioning Arduino, and Roadwarrior for pointing out the new Olimexino.

to merge my effort, I started embedded systems back in 1978. 1999 was my last upgrade to platforms using the then Motorola 56F803, a 16 bit processor. I came across the Arduino when looking for a Game platform.
I am also involved in Hybrid Electric Vehicle(HEV), that is where i ran into the Olimex .
I have over 30 processors running in my RV, on CANBUS that I am converting to Olimex.
why I use the board is it provides the schematic and board layout files that I can copy and past into the schematics I already have, then merge them.
Fulltiming since 1989.
No TLC's--
Accessing the internet with Wifi Evdo enabled mobile card from Verizon
Wifi SSID r0adwarrior on the road for Access to Internet, ask for Key.
Wifi SSID r0adwarrior for Access to Webpages in Bus.
http://roadwarrior.free-man.com/

#4 RV

RV

    Major Contributor

  • Validated Members
  • 8841 posts
  • SKP#:50964

Posted 30 March 2012 - 09:39 PM

Dugggg!
Hey now that sounds interesting. I'll be following your updates on this too!

Roadwarrior, you are also a surprise with every post. ;)

Edited by RV, 30 March 2012 - 09:45 PM.

RV/Derek
http://www.rvroadie.com Email on the bottom of my website page.
Retired AF 1971-1998


When you see a worthy man, endeavor to emulate him. When you see an unworthy man, look inside yourself. - Confucius

 

“Those who can make you believe absurdities, can make you commit atrocities.” ... Voltaire


#5 mrschwarz

mrschwarz

    Major Contributor

  • Validated Members
  • 734 posts
  • SKP#:109233

Posted 30 March 2012 - 10:05 PM

I will be following, too.

Michael

2010 Winnebago Tour
Cummins ISL 400
Allison 3000
Progressive EMS-HW50C Surge Protector
Blue Ox Aventa II
Air Force One
Tire Safeguard TPMS

Visit us at schwarz.org!


#6 Desolation Roe

Desolation Roe

    Major Contributor

  • Validated Members
  • 1919 posts
  • SKP#:106407

Posted 30 March 2012 - 11:37 PM

I will be following, too.


Me too.

I hope everyone had a great weekend. Snow here to day but supposed to be summer temperatures later thsi weekend.

Geo

George, Karen and Bubbles
2008 Volvo 780, 535hp 1850lb/ft D-16 I-Shift, 3.42
2005 Mobile Suites 38RL3

2014 Ford Expedition Limited


#7 Ned Pepper's chaps

Ned Pepper's chaps

    Senior Member

  • Validated Members
  • 140 posts

Posted 02 April 2012 - 01:22 PM

My Maple board hasn't arrived yet :mellow:

Man, now I want an automatic awning since I bout lost mine the other night. Dammit, now something else I want <_< Now I see why my wife fears my projects :lol:
"The cost of sanity in this society, is a certain level of alienation"
Terence McKenna

#8 Dugggg

Dugggg

    Major Contributor

  • Validated Members
  • 556 posts

Posted 02 April 2012 - 02:29 PM

Thanks all for the encouragement. My 8 y/o laptop croaked over the weekend while I was working on getting the Real Time Clock to work.  Replacement laptop is on its way, so RTC and LCD development should continue later this week.   Also ordered a $2 IR sensor, so that HAL can respond to commands from a handheld remote control.   Hope to get that working over the weekend.

The really cool thing is that all this work has already been done by others.   I just have to integrate these simple building blocks into a single "sketch" (Arduino lingo for C program) that displays the current time on the LCD---and allows the clock to be set or tweaked using the remote.

NPC, did you order your board from Mouser? They are often slow.

Edited by Dugggg, 02 April 2012 - 02:40 PM.

Fulltime boondocker for ten years, exploring AZ and NM with Bosco the cat

#9 Roadwarrior

Roadwarrior

    Major Contributor

  • Validated Members
  • 1054 posts
  • SKP#:111625

Posted 02 April 2012 - 04:36 PM

My Maple board hasn't arrived yet :mellow:

Man, now I want an automatic awning since I bout lost mine the other night. Dammit, now something else I want <_< Now I see why my wife fears my projects :lol:

Yup using the RV-C specs it has monitoring a weather station and awnings. I use din rail enclosures to make components that interface with sensors and controls like rolling up you awning.
Fulltiming since 1989.
No TLC's--
Accessing the internet with Wifi Evdo enabled mobile card from Verizon
Wifi SSID r0adwarrior on the road for Access to Internet, ask for Key.
Wifi SSID r0adwarrior for Access to Webpages in Bus.
http://roadwarrior.free-man.com/

#10 Ned Pepper's chaps

Ned Pepper's chaps

    Senior Member

  • Validated Members
  • 140 posts

Posted 02 April 2012 - 05:05 PM

The really cool thing is that all this work has already been done by others. I just have to integrate these simple building blocks into a single "sketch" (Arduino lingo for C program) that displays the current time on the LCD---and allows the clock to be set or tweaked using the remote.

Yeah, that's an huge plus for using arduino and arduino like mc's. It really is as easy as grabbing all the chunks of code you need and then sticking them together. It is sometimes a challenge to get different pieces to play nice with one another, but the bulk of the work has been done before you by some other gracious person. Three cheers for Open Source!

NPC, did you order your board from Mouser? They are often slow.


No, I went with the people you ordered from, but didn't order until recently. I wanted to get the rest of my gear first, which aint gonna happen it seems.

As an aside;
Just got back from the DMV and they would not accept our address or rental agreement as proof of residency. So, we are moving again, leaving Oregon. Oregon has not been a very welcoming place at all, this was the very last straw. I would say it was the straw that broke the camel's back, but I am not a camel, also my back was broke before I got here. In contrast, Colorado was a very easy and beautiful place to live. All my stuff will be on hold until I get settled, but I will be following your progress like a hawk.

RoadWarrior, you're like an encyclopedia, dude.

I'll stay focused on this forum in my down time, though I may not post. The rest of the board has lost any appeal it may have once had, but I like the tech tips forum alot.

Peace, guys, and good luck dugggg
"The cost of sanity in this society, is a certain level of alienation"
Terence McKenna

#11 Roadwarrior

Roadwarrior

    Major Contributor

  • Validated Members
  • 1054 posts
  • SKP#:111625

Posted 02 April 2012 - 06:42 PM

As an aside;
Just got back from the DMV and they would not accept our address or rental agreement as proof of residency. So, we are moving again, leaving Oregon. Oregon has not been a very welcoming place at all, this was the very last straw. I would say it was the straw that broke the camel's back, but I am not a camel, also my back was broke before I got here. In contrast, Colorado was a very easy and beautiful place to live. All my stuff will be on hold until I get settled, but I will be following your progress like a hawk.

I feel for you, had to deal with this all the time, since I don't have a permanent address.

RoadWarrior, you're like an encyclopedia, dude.

My business is system integrator using embedded system, since the 70's.
like my tag says Men and their toys.
I get paid to play with my toys.
Fulltiming since 1989.
No TLC's--
Accessing the internet with Wifi Evdo enabled mobile card from Verizon
Wifi SSID r0adwarrior on the road for Access to Internet, ask for Key.
Wifi SSID r0adwarrior for Access to Webpages in Bus.
http://roadwarrior.free-man.com/

#12 Ned Pepper's chaps

Ned Pepper's chaps

    Senior Member

  • Validated Members
  • 140 posts

Posted 02 April 2012 - 07:37 PM

I used to know more about embedded stuff, not as much as someone like you, but more than I do now. I left a goodly amount of my memories (along with the top of my left ear) in a ditch somewhere in Pennsylvania. Not exactly sure where as I do not remember any of the accident. It's funny because it's only now, two years later, that I'm really starting to see the extent of the injuries to my brain. People I've known for years, I cannot remember their names etc. I haven't yet determined if new memories are in danger of sudden evaporation, but I think not. I do look forward to learning a lot from what dugggg has to go through and I imagine you'll be the goto guy for pulling all the pieces together.

This is gonna be pretty badass.
"The cost of sanity in this society, is a certain level of alienation"
Terence McKenna

#13 Dugggg

Dugggg

    Major Contributor

  • Validated Members
  • 556 posts

Posted 07 April 2012 - 01:31 PM

Well, I got the replacement laptop. Unlike my ancient Dell, the new Asus a 64-bit architecture. I downloaded the latest version of Ubuntu, another hour of updates, went to run the Maple IDE (the Java software used to write, compile, and upload the programs)---and ran into a Java error. Turns out Maple IDE libraries weren't compiled for 64-bit systems. Spent hours this morning Googling and trying various workarounds to no avail. Might be a bug in the Java toolkit itself. So rather than spending countless days learning Java and trying to reverse-engineer the problem, I think I will simply wait til later this month, for 12.04, the next major Ubuntu release. A 64-bit Maple IDE might be out by then as well. Meanwhile, a hardware snag. Turns out most of the Arduino peripherals are designed for 5-volt systems---and HAL is 3.3V. This means the 5V,$5 LCD I ordered didn't work---the display was barely readable at only 3.3V. So I have ordered a 3.3V version, again for $5, that should arrive from China in a couple of weeks.
Fulltime boondocker for ten years, exploring AZ and NM with Bosco the cat

#14 Roadwarrior

Roadwarrior

    Major Contributor

  • Validated Members
  • 1054 posts
  • SKP#:111625

Posted 07 April 2012 - 02:19 PM

Java needs the JDK runtime from Oracle.
Compile maple java is in P code format and uses a interpreter. the code will work on any platform that there is a Runtime loaded.
I suggest you go to Ubuntu forum and ask them.
you can download the Src for maple


be careful of the serial it is not a through hole but a smd.
won't handle much strain.

pm me I will buy the 5v since I have a Arduino, maple as well as the OLIMEXINO-STM32

Edited by Roadwarrior, 07 April 2012 - 02:46 PM.

Fulltiming since 1989.
No TLC's--
Accessing the internet with Wifi Evdo enabled mobile card from Verizon
Wifi SSID r0adwarrior on the road for Access to Internet, ask for Key.
Wifi SSID r0adwarrior for Access to Webpages in Bus.
http://roadwarrior.free-man.com/

#15 Ned Pepper's chaps

Ned Pepper's chaps

    Senior Member

  • Validated Members
  • 140 posts

Posted 07 April 2012 - 10:54 PM

I never use the 64 bit releases and I have 2 64 bit machines, it just always causes trouble with stuff like this, well it always just causes trouble period. Another issue you might have is with librxtx, one of the java files for serial communication. that may have just been a problem with the Arduino IDE, idk

I got my board a couple days ago, but haven't played with it yet since I still have no components, breadboard etc. How is Ubuntu 12? I haven't even looked at it. I hate 11.04, though. I been sitting here for 3 hours trying to find out what happened to seahorse-plugins. As of now I'm having to encrypt on the command line, which blows (go ahead guy from the windows 8 thread, say I told you so :rolleyes:)

Edited by Ned Pepper's chaps, 07 April 2012 - 10:54 PM.

"The cost of sanity in this society, is a certain level of alienation"
Terence McKenna

#16 VallAndMo

VallAndMo

    Senior Member

  • Validated Members
  • 181 posts
  • SKP#:116835

Posted 08 April 2012 - 07:10 PM

Hey Dugggg and Ned,

Very interesting thread! Vall works with computers and has a lot of C programming and Linux experience, and some experience with Arduino microcontrollers, so we will be sure following your progress.

Cheers,
--
Vall & Mo.

Getting ready to join the RV full-time lifestyle in late 2015!


#17 RV

RV

    Major Contributor

  • Validated Members
  • 8841 posts
  • SKP#:50964

Posted 08 April 2012 - 08:48 PM

No Ned,
If you're talking to me, I wish you well! See it is folks like you who I will crib from with my Pi. I hope you can get it all worked out like you want. I had all the all nighters doing early adoption of hardware that I wanted. That's why I will be playing with a ready made mini computer that I just have to load Linux on. And one with a UI.
Hang in there you'll get it. B)

RV/Derek
http://www.rvroadie.com Email on the bottom of my website page.
Retired AF 1971-1998


When you see a worthy man, endeavor to emulate him. When you see an unworthy man, look inside yourself. - Confucius

 

“Those who can make you believe absurdities, can make you commit atrocities.” ... Voltaire


#18 Dugggg

Dugggg

    Major Contributor

  • Validated Members
  • 556 posts

Posted 09 April 2012 - 12:46 PM

Ned, right you are about Ubuntu amd64. I reverted to an old 32-bit copy of 10.04 and voila! Back in business. Even bypassed Java altogether by installing the Unix toolchain which is an easier interface for programmers. Spent most of yesterday finishing up the onboard Real Time Clock stuff. It works pretty well, though it seems to lose a small bit of time during bootloading. But good enough for government work. Can't wait for the new LCD to arrive!

Edited by Dugggg, 09 April 2012 - 12:55 PM.

Fulltime boondocker for ten years, exploring AZ and NM with Bosco the cat

#19 Dugggg

Dugggg

    Major Contributor

  • Validated Members
  • 556 posts

Posted 10 April 2012 - 10:42 PM

Today I received the $2 infrared sensor from Adafruit. Pleased to report works with 3.3 volts. I wrote the following sketch from scratch after determining Adafruit's example Arduino code would not work well on the Olimexino-STM32. The next step will be inserting this new code into the RTC code, so that any stray seconds are rounded forward or backward to the nearest minute at the press of a button from my Lazy Boy.



// IR Remote Decoder                              April 10, 2012


// This sketch uses the inexpensive GP1UX311QS IR sensor to see if a button
// has been pressed on a common 24-button IR remote.   Using an interrupt 
// routine that is called whenever the sensor's output state changes, it 
// captures the duration of each state in an array.   After a brief period of
// silence, it then compares the packet received to the known patterns
// associated with each button press, defined in irhash.h.

// A signal is any digital transition of the IR sensor.  A packet is a series
// of signals, the lengths of each of which are stored in an array.   A 
// pattern is a packet of recognized length and structure, most likely 
// representing the press of an IR remote button.

#include <wirish.h>
#include "irhash.h"


#define prtln SerialUSB.println

#define IR_PIN  7  // board pin connected to pin 1 of the IR sensor
#define PAT_LEN  72  // button packets have a recognized pattern
#define PAT_MIN_IDX 36 // the varying part of the pattern starts here...
#define PAT_MAX_IDX 59 // ...and ends here.   The rest of the pattern is fixed.


#define MAX_INT 2100000000 // close enough
#define MAX_PACKET_LEN 500
#define MAX_NOISE 500 // max usecs for noisy signals
#define MIN_SILENCE 50000 // usecs of silence betfore acting on packet

unsigned short packet[MAX_PACKET_LEN];
int packet_idx=0;
int last_idx = 0;
int last_micros = 0;
int min_len = MAX_INT;
int cmd_pending = 0;


int pat_hash(void)
{
   // This function returns a (hopefully unique) numeric value 
   // representing the varying portion of a known pattern---for easy
   // use in a switch statement.
   
   int hash = 0;

   for (int i=PAT_MIN_IDX; i<(PAT_MAX_IDX); i++)
   {
   	hash += packet[i] /= min_len;
   	hash *= 2;
   }
   
   return hash;
}

void ir_sig(void) // interrupt handler called every time IR sensor changes
{
   int m = micros();
   int gap = m - last_micros;


   if (gap > MAX_NOISE) // ignore short signals which are usually noise
   {
 
      // discard the whole packet if it's too big for the array
      if (packet_idx >= MAX_PACKET_LEN) packet_idx = 0;

      packet[packet_idx++] = gap;
      last_micros = m;
 

      if (gap < min_len) min_len = gap;
   }
}

void compare_pattern(void)
{
   switch (int i=pat_hash()) // express pattern as a hash value
   {
      case CH_BRIGHTER: prtln("brighter"); break;
      case CH_DIMMER: prtln("dimmer"); break;
      case CH_ON: prtln("on"); break;
      case CH_OFF: prtln("off"); break;
      case CH_R: prtln("R"); break;
      case CH_G: prtln("G"); break;
      case CH_B: prtln("B"); break;
      case CH_W: prtln("W"); break;
      case CH_FLASH: prtln("flash"); break;
      case CH_STROBE: prtln("strobe"); break;
      case CH_FADE: prtln("fade"); break;
      case CH_SMOOTH: prtln("smooth"); break;
      default: SerialUSB.print(i); prtln(" unassigned");
   }
}

void check_ir(void) // see if a known IR packet has been received
{
   int m = micros();

   if (packet_idx > last_idx) // 
   {
      last_idx = packet_idx;
      cmd_pending = 1;
   }
 
   // Wait a brief period of time without any signal to ensure that
   // an entire packet was received.   MIN_SILENCE must be longer than
   // the length of time required to receive a packet of interest.  
 
   if (cmd_pending && ((m - last_micros) > MIN_SILENCE))
   {
      // if packet is of a known pattern length, look into it
      if (packet_idx == PAT_LEN) compare_pattern();

      // in any case, now start over looking for another packet
      cmd_pending = 0;
      packet_idx = 0;
      last_idx = 0;
      min_len = MAX_INT;
   }
}

void setup(void)
{
   attachInterrupt(IR_PIN, ir_sig, CHANGE);
}


void loop(void)
{
   check_ir();
}

Edited by Dugggg, 10 April 2012 - 11:35 PM.

Fulltime boondocker for ten years, exploring AZ and NM with Bosco the cat

#20 VallAndMo

VallAndMo

    Senior Member

  • Validated Members
  • 181 posts
  • SKP#:116835

Posted 11 April 2012 - 03:17 AM

Way to go, Dugggg!

Vall would never have guessed, when we joined that forum about a year ago, that someday he would see full-blow C code for a microcontroller being posted here, much to his pleasure, we might add!

Also, kudos on bypassing the Java interface... real programmers work with "vi" in one screen and "make" in another! ;-)

Cheers,
--
Vall & Mo (specially Vall)

Today I received the $2 infrared sensor from Adafruit. Pleased to report works with 3.3 volts. I wrote the following sketch from scratch after determining Adafruit's example Arduino code would not work well on the Olimexino-STM32. The next step will be inserting this new code into the RTC code, so that any stray seconds are rounded forward or backward to the nearest minute at the press of a button from my Lazy Boy.



// IR Remote Decoder                              April 10, 2012
(...)


Getting ready to join the RV full-time lifestyle in late 2015!