Newbie Seeking Guidence on Software and Hardware

Hi!

One of the techs at work turned me onto Arduino for a system redesign. My plan was to use an atmel micro-controller, and I was nit-picking at the details of power decoupling and he said "Hey! take a look at this." Wow, what an amazing concept! These little boards are neat for the price, and are perfect for my one-off projects.

What I'm hoping to get feedback for is primarily how I should approach my software setup for this project. More specifically:

  • Should I fuss with interrupts? Or should I just write one big loop that goes on until power is shut off? I could, for instance, tie my switch changes to interrupt pins...
  • Should I store data on my system layout and write simplified code that processes this data, or should I hard code it all into instruction memory?
  • How should I handle memory and instruction memory faults? I need to understand the possible failure modes and be able to address them with additional components.

The project is a high pressure test system. The controller will sample the states of DTSP switches (on-off-on) to determine the state of valves (driven by relays) and light indicators (R/Y/G/Off Quad-state). The controller will also need to take into account various fault conditions and respond appropriately. On top of all that, my controller will need to be able to tell my computer what it is up to (What are the valve and fault conditions), and take input from the computer (if a particular switch for a control is in the middle position, then the computer is driving that control).

The vast number of I/O I need for this has led me to the Seeeduino Mega. Nice little board. I've already programmed a few example/learning programs on it just to familiarize myself with the platform (I've been programming for years, but only messed with MCUs back in my college days for a senior project).

My goal is to route all the signals via a "shield" that will adapt to the top of the Seeedunio Mega, and those signals will go through what ever "glue-logic" is needed into ribbon cable headers. The ribbon cables will terminate on DIN Rail terminal blocks (such as Altech FBK34 and such) and from there go to my various components.

The software I'm using on the computer to communicate with the MCU will be coded in LabVIEW. I've played around with this already, and am confident that this will work... I think :P. I definitely need to be careful not to lose this USB connectivity functionality by having something on a PIN that interferes with this (It looks like most of the pins are multi-functional).

I've worked out a spreadsheet of all my connections against Seeedunio pins so I can start making some decisions on what I want, where. Already I'm seeing a need to move some of my outputs around.

Here is a link to that table (Excel 2003, let me know if you want me to convert it to something else), as I think it illustrates the size and scope of my project. :o

Edit: I guess I will post it in my follow up message because it is telling me I need to post 1 normal message or something.... I guess spam has to be fought somehow.

Thanks for your input! I'm really excited to get going on this Arduino approach to MCU design as it compliments my job requirements very well. It is also refreshing to see a thriving community around it ;D.

-Nickerbocker

Here is the link to my spreadsheet of connections:

https://files.me.com/nickerbocker/i61f1x

Clicking the link you provided...

[WinZip]
Internal error detected
WInZip will exit. Please re-start WinZip and try again.

The project is a high pressure test system

High pressure in the "1000 psi" sense? In the, "someone will die if this doesn't work" sense? In the, "I'm gonna lose my job if this doesn't work" sense?

The controller will also need to take into account various fault conditions and respond appropriately

Is property or life at risk?

Idk... The zip file opens fine on my end using the compression utility in Windows XP. People still use WinZip? Tried WinRAR out, and it unzipped just fine too.

High pressure as in >10k psig. And I work with these systems (have for years). They are behind concrete walls. Personal isn't allowed w/o proper safety apparel and everything is controlled remotely. There are also mechanical safety mechanisms in place. There should be no such system where an electrical fault causes catastrophic failure. But thanks for your concern. Property may be at risk at times (depending on the test configuration)... but that the nature of the business. No one's life is ever really at risk... high pressure == life threatening if proper safety mechanisms are in place and volumes are limited.

But the way you talk, are these Arduino's not very reliable? Is it a wrong design choice to go with these due to problems with them?

I would like to do some kind of a checksum on instruction and data memory every so-often to ensure there are no MCU faults.

But the way you talk, are these Arduino's not very reliable?

I do not have the experience necessary to know if they are or are not reliable. In addition, you have not stated what "reliable" means to you so it would be impossible for anyone to accurately answer your question.

Is it a wrong design choice to go with these due to problems with them?

Only you can make that assessment.

But the way you talk, are these Arduino's not very reliable?

They are reliable, but they're not designed to industrial standards - this is a hobbyist forum.
They don't have input protection, other than that provided by the built-in devices on the MCU.

You generally have 6 problem zones with microcontroller systems (note that I do not talk of the chip, but of the complete assembly of PCBs in a housing).

(1) Validity of the (VLSI) chips under normal operation conditions (temperature, supply voltage, input voltage, output current), This is generally very high. So there is no need for memory consistancy checking or such for hardware reasons.
(2) Stability of supply voltage. Tricky matter if you have to reliably handle powerdrops...
(3) System design with respect to I/O. This is often a main problem zone. You have to secure against high input voltage, output shortcuts, RF interference. This can cost you $5 per pin. I say this to show you that the price of a naked Arduino system is not an relevant asset item. However there are also low cost solutions. My recommendations are 74HC4049 for inputs and ULN2308 for outputs. But this is low cost and might not suffice....
(4) Quality of PCBs, wiring, and mechanical build, especially wrt to ground connections, temperature, moisture, and EMC...
(5) Connectors
(6) Correctness of Software. My guess is that 90% of your trouble will be here :slight_smile:

  • Should I fuss with interrupts? Or should I just write one big loop that goes on until power is shut off? I could, for instance, tie my switch changes to interrupt pins...

In your case with MANY and systematic I/O operations a loop will allow you a much better code overview and also precise timing. From your description I see no need for special interrupts at the moment, but this can be added later. Not thst the serial transmission to the PC is blocking; this has to be carefully examined by you.

  • Should I store data on my system layout and write simplified code that processes this data, or should I hard code it all into instruction memory?

I think your application looks like "table driven".

  • How should I handle memory and instruction memory faults? I need to understand the possible failure modes and be able to address them with additional components.

You have no protection against software issues. But you could use the watchdog (or even an external watchdog) to restart your system when lost.... An initial "sanity check" (or "BITE") would be nice, but needs additional external hardware...

Thanks for all of the helpful responses. I see that Arduino is for hobbiest but it is an attractive alternative to the expensive FPGA industry. A lot of shops, like mine, do one-off jobs. We can't design things in such a way that we plan to recoup cost by making many-many units.

I have experience with writing assembly for PIC microcontrollers (back in college days). A lot of our system control has been done using multifunctional DAQ boards and Windows based machines. Windows reliability...well, its crap. Thats why we protect ourselves by mechanical means (I don't think any level of reliability would change that, tbh). Windows faults happen, and the response is to shut off power which switches everything into a safe state.

So..when it comes to reliability, would an Arduino board offer more or less reliability than a Windows machine if properly programmed and interfaced with external hardware?

deSilva: Your info is very helpful for me! Thanks for the feedback. Once I nail down my pin assignments, I was considering using the on-chip EEProm to save my various assignments. I won't need to change these very often so the 100,000 write/erase limitation does not concern me. The main program will mostly be reading from the EEProm in a loop.

This is all coming together in my head. I have a feeling I'm going to be making a prototype before I make a production unit. ;D

As far as external watchdogs go, whats a good example?

My first thought is to have my program loops generate some square wave on a pin. Filter that output with a capacitor and diode feed it into an op-amp configured as a comparator. So long as the program is still chugging away the square wave will be produced. If there is some fault that stops the program counter from moving forward the squarewave stops and I can have it indicate something on a panel or kick off system power. Just a thought...

I like the approach of using the EEProm to store my "system configuration"... maybe I could do a checksum on this as another fault detection.

Not thst the serial transmission to the PC is blocking; this has to be carefully examined by you.

Thanks! I've highlighted pins 0 and 1 and will make sure no connections exist there. I'm also going to leave 21 (SCL) and 20 (SDA) free just in case I need some I2C communication later. My boss may come around asking me to double the number of components :o

Blocking.
This is a software issue. The print-library will wait until all characters have been sent. This is not acceptable for a tight main loop! You have to find a work-around (not really difficult)

Watchdog.
I should recommend the internal watchdog - see Arduino playground example. External solutions can comprise anything from a second processor, downto a retriggerable one-shot, in the easiest case a cap to be pulse charged, similar to your own idea.

EEPROM
Tables in EEPROM make sense if you have to put your code under strict revision control, and you have a tool to generate an EEPROM table. I think this is not worth the trouble. You can include all configuration tables in the FLASH area (C-tag PROGMEM)... All right, apart from the system has to be dynamically re-configured

Thanks again for the reply, deSilva. When you say c-tag PROGMEM, are you saying I should just create some arrays in my initial setup function, and in my program loop, loop through those arrays? I did a search of that term "c-tag PROGMEM" and Google brought me back to this post (dang they're fast).

Hehe, I'd already started laying out my 512 bytes of EEProm memory in my spreadsheet. I guess what I was planning to do was write up a function on my Ardunio that allowed programming to the EEProm (using the library functions), and have this accessible via a serial command, then use some windows software I wrote to write the table up.

I think it is desirable to have the fault conditions (i.e., Fault0 pin goes high, what are the Relay0-15 outputs when this happen) to be configurable. System changes happen often enough that change how we want the faults to be handled....reprogramming the MCU doesn't seem like a desirable approach to me.

What Relay output responds to What Switch input and turns on What Light output won't change hardly at all. And if it does change, I would be involved and be OK with reprogramming the MCU.

What you do is fine, but also error prone... It is the missing "tool" I was referring to :slight_smile:

Edit:
As you have a lot of RAM memory in the MEGA it might even suffice to keep everything in the RAM. This will simplify programming considerably.
The compiler generates initialization code to copy all presets in the RAM...

Edit2:
I just read your paragraph about "involvement". I see the danger that the configuration might become unmaintainable by permanent and uncontrolled changes

Ahh ok, gotchya. Thanks for the reply :).

@daSilva would you mind clarifying your thought here:

Edit2:
I just read your paragraph about "involvement". I see the danger that the configuration might become unmaintainable by permanent and uncontrolled changes

I think I have all the code worked out (indicators, relays, fault conditions, and computer interface). I've been playing with a mock up design on a breadboard using an Arduino Nano and am about to start working on a Shield for the Seeeduinio Mega.

Those parts that were linked by daSilva look promising... however, all of the controls and indicators run on 24V. It would be nice to protect my inputs and outputs from accidentally be crossed with 24V.

Using this optoisolator: Intelligent Power and Sensing Technologies | onsemi

that I had in my shop left over from a previous project, and a series 820 ohm 1W resistor, I was able to put up to 30V on the input pins and not smoke anything. Circuit still works fine off 5V.

I think I'm going to use this for my input pins...