Pages: [1]   Go Down
Author Topic: My first Arduino project - multi emulator  (Read 2153 times)
0 Members and 1 Guest are viewing this topic.
Melbourne, Australia
Offline Offline
God Member
*****
Karma: 8
Posts: 567
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset



I finished the enclosure today and the hardware last night. Probably 15 years of software tweaking to do  smiley-roll-sweat but I am a software developer with perfectionist tendencies so that's only to be expected.

I'll do a video to show the menu in operation, one day, but other than this pic there's probably not a lot I can talk about as it's for work purposes and wouldn't make a lot of sense to anyone beyond myself and 5 people at work.

This is an Arduino Mega with protoshield and LCD + keypad shield. 4 x switches are digital inputs, 2 x trim pots are analog inputs. The code it runs lets you select one of 2 sensor control boxes and then emulates the chosen one. The switches and pots allow you to simulate various conditions typically encountered in the field - like opening and closing valves or specifying leak rates and what not.

The only hardware change I'd like to do is to add 2 more serial USB ports (the Mega chip has 4xUARTs so it's definitely doable in hardware) so I can simulate 2 x control boxes talking to the PC at once, plus another USB port to talk to a terminal app running on the PC for debugging purposes. Going to order the parts to do that tonight.

Control box 1 talks at 9600 baud
Control box 2 talks at 115200 baud

I loved the fact that you could switch baud rates on the fly - very handy.

The software I am developing for work polls the control boxes at 1 second intervals, so there's plenty of time for handling key presses and checking for changes in analog or digital inputs.

I may create a library for the (very simple) menu system, once I've got up to speed with function pointers and massaged it into a truly dynamic menu system. So far I have main headings, sub menu options and radio buttons implemented. I don't need much more than that, so won't do any more. I just downloaded the SimpleTimer.(h/cpp) library for the code examples, so maybe the menu library will help someone else.

Everything else in the code is very specific to the proprietary firmware and control sequences used by work hardware / software so there is nothing I can really release for  others to use / incorporate. I'm putting some time into answering questions here though, so hopefully my nett karmic balance stays positive.

The biggest challenge for me, for the entire project, was getting the enclosure drilled out accurately.  smiley-confuse Far out.


I am enjoying the process of learning this technology, and have many, many ideas brewing. Have also just located a local hackerspace, so hopefully I can get involved there and get up to speed with the gaping holes in the knowledge I need to implement those ideas.

I'll leave you with a little bit of code from the sketch. The entirety of my loop and serialEvent functions:

Code:
void loop() {
  if (keyPressed()) handleKeyPress();
  if (stateChanged()) displayState();
}

void serialEvent() {
  if (cmdReceived()) handleCommand(); 
}

Logged

Windows serial port monitor: Tellurium | Arduino serial port debugging library: DBG | Cusom LCD char generator | Technical questions will only be answered in forum threads

Melbourne, Australia
Offline Offline
God Member
*****
Karma: 8
Posts: 567
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Lessons learnt:

1. if your digital input via a switch with pull-down resistor is displaying hysteresis, you are probably doing something wrong - more likely than not your connections are not solid.
2. Protoshield mega is absolutely brilliant for the Arduino Mega.
3. Screwing the LCD + keypad shield into the top of the enclosure too firmly is probably also pressing the reset button down. Better back those screws off a smidge, mate.  smiley-red
4. Function calls will compile without their parentheses, but not actually do anything.
Logged

Windows serial port monitor: Tellurium | Arduino serial port debugging library: DBG | Cusom LCD char generator | Technical questions will only be answered in forum threads

Melbourne, Australia
Offline Offline
God Member
*****
Karma: 8
Posts: 567
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

One more image smiley-wink

I did an assoc diploma in EE a few years after completing my BSc in Stats / Info systems / Comp Sci, but have forgotten pretty much all of it. It's slowly coming back, and I am making mistakes, but when it finally clicks, you realise you don't need 4 separate ground terminals for 4 x switches, you can just use one. Like this:



Going to be a bit of work to get the Rx/Tx pins out of the board when I integrate a couple more USB ports, but shouldn't be too bad...
Logged

Windows serial port monitor: Tellurium | Arduino serial port debugging library: DBG | Cusom LCD char generator | Technical questions will only be answered in forum threads

Colorado
Offline Offline
Edison Member
*
Karma: 47
Posts: 1562
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Looks like a cool device.  At some point, you may want to consider making a custom board as opposed to using a proto shield ontop of a mega.
Logged

Melbourne, Australia
Offline Offline
God Member
*****
Karma: 8
Posts: 567
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Looks like a cool device. 

Thanks! smiley-grin

At some point, you may want to consider making a custom board as opposed to using a proto shield ontop of a mega.

That's the next step, isn't it!?

The Mega has more inputs than I have had hot breakfasts, and I am using uh 6 of them. smiley-confuse

I got the Mega because it had 256k of flash. I didn't want anything getting in the way of my C programming, and that was the most memory in any of the units. The sketch running currently weighs 12kb.  smiley-eek-blue Lots of room for expansion...

I am putting in an order for a 8, 14 and 20 pin ICs that I can stick in a breadboard and get up to speed with - all with varying amounts of Flash memory, I/O pins, etc. So I can get a feel for capacity of code and what not.

It hurts me from an efficiency POV to have such a powerful IC doing such a mundane job, but it's already helped uncover a potential bug in the software I am writing for work, so it's definitely been worth doing.

The projects after this one will be more embedded in nature, so size will be a consideration, and trading off power / capability / capacity with footprint will practically require a custom board being designed and manufactured - I am looking forward to that process.

Have you designed a custom board yourself?
Is Eagle good enough?

I am really keen to make it SMD so have been watching reflow videos with ovens and heat guns. Am very excitement about the possibilities.
Logged

Windows serial port monitor: Tellurium | Arduino serial port debugging library: DBG | Cusom LCD char generator | Technical questions will only be answered in forum threads

Colorado
Offline Offline
Edison Member
*
Karma: 47
Posts: 1562
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The Mega has more inputs than I have had hot breakfasts, and I am using uh 6 of them. smiley-confuse

I got the Mega because it had 256k of flash. I didn't want anything getting in the way of my C programming, and that was the most memory in any of the units. The sketch running currently weighs 12kb.
Ouch ... smiley  You'd be surprised how much you can fit inside of 32K.

Have you designed a custom board yourself?
Is Eagle good enough?
Plenty, and more than just "good enough".

I am really keen to make it SMD so have been watching reflow videos with ovens and heat guns. Am very excitement about the possibilities.
My very first board had SMD parts on it ... I didn't bother doing any practice soldering, I just jumped in.  Other than one miscalculation with a regulator (which was solved by cutting the trace and soldering a jumper wire.)  Since then I've done several others, both for myself, as well as for others (paid.)

I don't use neither an oven nor a heat gun.  I use the skillet method.
Logged

Melbourne, Australia
Offline Offline
God Member
*****
Karma: 8
Posts: 567
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Nah my mate Bill reckons you need 640k for programmers, so I went with the biggest I could find.

There's a lot more code to go into this project yet, I think I am going to hit the 32k mark by the time it is finished...

Thanks for the confirmation of Eagle - the challenge from my reading to date is knowing how to track down the part footprint you want to put in the design.

Your custom boards sound interesting - do you have a link where I could check them out? I'll go research skillet method now...

My ambition currently far outstrips my ability, but the ideas I am having are keeping me awake at night.  smiley-lol
Logged

Windows serial port monitor: Tellurium | Arduino serial port debugging library: DBG | Cusom LCD char generator | Technical questions will only be answered in forum threads

Melbourne, Australia
Offline Offline
God Member
*****
Karma: 8
Posts: 567
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is that an electric skillet?
Logged

Windows serial port monitor: Tellurium | Arduino serial port debugging library: DBG | Cusom LCD char generator | Technical questions will only be answered in forum threads

Colorado
Offline Offline
Edison Member
*
Karma: 47
Posts: 1562
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Electric skillet ... hot plate ...stove top frying pan ... they all work.  SparkFun has a tutorial on using a skillet.  Scroll half way down the page.

Because most of my projects and designs are personal stuff, I don't bother to document them.  There is a one-time-only design that I created for a group of kids at a local high school.  I attached a composite image which shows the various stages of the product.  I didn't write anything about it.  I should remedy that one of these days ...

My current (paid) project is a board designed to control a bunch of sensors together.  I attached an image of that as well.


* Composite.jpg (345.33 KB, 1024x768 - viewed 79 times.)

* 20121210-999.jpg (424.17 KB, 1024x765 - viewed 70 times.)
Logged

Melbourne, Australia
Offline Offline
God Member
*****
Karma: 8
Posts: 567
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I read that tutorial about 5 minutes after you mentioned skillet smiley-wink

That first board looks awesome - did they talk to one another in the classroom or something?

Do you have a back ground in EE or similar? Just wondering how difficult it is to get up to speed on circuit design. One good thing is all the open source schematics around should provide a good starting point - certainly for wiring up the bare essentials for the processor, etc.
Logged

Windows serial port monitor: Tellurium | Arduino serial port debugging library: DBG | Cusom LCD char generator | Technical questions will only be answered in forum threads

Melbourne, Australia
Offline Offline
God Member
*****
Karma: 8
Posts: 567
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've been researching chips for one of the project ideas I have and they are so incredibly inexpensive.

Do you have any recollection of how much your first board cost?

PCB manufacture + BOM for all components?
Logged

Windows serial port monitor: Tellurium | Arduino serial port debugging library: DBG | Cusom LCD char generator | Technical questions will only be answered in forum threads

Colorado
Offline Offline
Edison Member
*
Karma: 47
Posts: 1562
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The first board is an LED controller that talks to other nodes via RF.  Each board had two strings attached to it (labeled A and B on the left side) and a master controller sent signals to change all the controllers.

If I remember correctly, it came out to a little under $5 per unit.  That did not include the red RF module though, that was purchased ready-made from SFE.  My cost include PCB production both for the controllers as well as the LED strings as those were custom made, and all of the parts for the controller and LED strings.  Some of the parts, specifically for the LED strings, were purchased directly from China.  Even with shipping, it was still cheaper than buying them in the US.
Logged

Pages: [1]   Go Up
Jump to: