Show Posts
Pages: [1]
1  Topics / Product Design / Re: Hysteresis and Safety in a Heater Controller on: October 30, 2011, 07:17:53 pm
If I understand the question correctly, I guess it means that the heater could run indefinitely. So, I guess some sort of timeout might be good to implement some sort of timeout.

Now, I should also note that I've been looking around for a thermal fuse to shut the whole kit and kaboodle down if things get out of hand.
2  Topics / Product Design / Re: Hysteresis and Safety in a Heater Controller on: October 27, 2011, 07:27:42 am
Excellent. Thanks for the information.
3  Topics / Product Design / Hysteresis and Safety in a Heater Controller on: October 26, 2011, 12:05:09 pm
I've made a very simple heater controller with my Arduino and incorporated some hysteresis in software like so:

Code:
if (temperature < (setTemp - HYSTERESIS)) digitalWrite(TRIAC_PIN, HIGH);
if (temperature > (setTemp + HYSTERESIS)) digitalWrite(TRIAC_PIN, LOW);

That's the core of the temperature controller. It works fine. (Well, my simulation using the built-in LED works fine, but I haven't connected the heating element yet.) Anyway, I see that when we are in the no man's land between the high and low borders of the hysteresis loop, the state of the TRIAC_PIN stays whatever it was previously. When I think about it, I see no problem with this. The system will leave that area at some point and the controller will take charge again. But considering we're dealing with 120VAC and a heating element here, I want to make sure there is no logic error there that can allow some sort of runaway condition.

For that matter, can anyone refer me to some information on programming for safety? In my day job I do this sort of thing with relay logic all the time. But programming, though similar, is a different story. I'm not using pointers or passing arrays to functions, so I don't think I have to worry about memory leaks. What else should I look out for?

Thanks a lot for your help.
4  Using Arduino / Programming Questions / Re: Problem Connecting Arduinos Over Serial on: October 03, 2011, 09:21:27 am
I got it working, more or less, when I switched the code loaded on the Pro and the Duemilanove so that I could unplug the FTDI Basic breakout from the programming header and just use it straight with a ground and serial in. (That is, I used the Pro instead of the Duemilanove as the device that was both sending and receiving.) It's quite inconvenient, of course, to have to unplug and replug the programming cable while debugging, so I'll try NewSoftSerial to communicate between the boards and the normal serial to go to and from the computer.

I say I got it working "more or less" because when I tried to re-complicate my code it stopped working. But the bare bones serial echo worked finally. I'll work on it and post again if I get totally stuck.

If it comes to it, I will use the SPI serial monitor code from that forum post (not I2C because I plan to use it later as part of this project). I don't have enough Arduinos right now, but I plan to get a few more soon, and this SPI serial echo method looks excellent for troubleshooting.

Thanks

EDIT: I should have been more ebullient in how neat Mr Gammon's SPI echo idea is. I really like the concept for this project and the future and thanks for the link.
5  Using Arduino / Programming Questions / Re: Problem Connecting Arduinos Over Serial on: October 02, 2011, 06:01:50 pm
I've tried Serial.print() as well. I must say it's not very scientific at this point because I've tried everything every way but without clean documentation. That said, with Serial.write() or Serial.print(), the console just tries to interpret it as ASCII anyway and gives its best guess, which I can usually interpret well enough to see if it's doing something roughly correct. So the first few are blank, but then it goes through punctuation, letters, numbers, special letters, and so on. Also, at first I formatted it as Serial.println(counter, DEC); just to make sure it was working before I went to sending pure bytes.

I'm wondering if the Arduino does some shenanigans with its serial port when it's being used over USB. I know it resets when I load up the console, so does whatever causes that cause me problems here? I don't have another Pro right now to test it.
6  Using Arduino / Programming Questions / Re: Problem Connecting Arduinos Over Serial on: October 02, 2011, 05:45:40 pm
I'll read through that link. I tried SoftwareSerial a little bit (not NewSoftSerial, though). I might also just try a different board. The problem is I don't have any more Arduinos right now (not 5V ones at least).

I put a sketch of the wiring over here: http://squishyrobot.files.wordpress.com/2011/10/img_20111002_182620.jpg

Note that I'm using power off the Duemilanove to power the Pro because at times I would remove the FTDI board to see if it works. I connected it to Vin on the Pro because it didn't seem to work on Vcc (I've done so many things it's hard to recall anymore).

So here's what I did:
1. Load up the "receiver" code from my previous post.
2. Set serial to COM3 and set the board to the Duemilanove.
3. Upload the program.
4. Load the "transmitter" code.
5. Set serial to COM4 and set the board to the Arduino Pro 5V/16MHz.
6. Upload the program.
7. Open the serial console (we're still on COM4) and make sure it's listening at 1200.
8. Observe a serial stream of ASCII characters from 0 to 255 over and over again.
9. Change to COM3 and load up the serial console again (this should be the Duemilanove now).
10. Absolutely nothing happens.
11. Uncomment the "Waiting" line, reload (making sure to set the right COM port and Board).
12. Observe "192Waiting" over and over again on the console. (The actual number will vary from line to line.)

This looks almost like it might be right, but it doesn't show all the numbers, even if I cut the transmission time to one byte every 100ms. It looks like it might be garbage numbers because it stays up near 190-250 or so.
7  Using Arduino / Programming Questions / Problem Connecting Arduinos Over Serial on: October 02, 2011, 04:11:46 pm
I'm running some tests so that I can ultimately connect two Arduinos with those really cheap wireless modules. I've been paring down my code all day until getting to the bare bones you see here to isolate my problems. Right now I have an Arduino Pro (5V/16MHz) as the "transmitter" wired directly from pin 1 to pin 0 on a Duemilanove. The Pro is running this code:

Code:
byte counter;
void setup() {
  Serial.begin(1200);
  counter = 0;
}
void loop() {
  Serial.write(counter);
  counter++;
  delay(10);
}

When I watch it on the console through my FTDI Basic it looks like it's working. So, I load the following code on the Duemilanove:

Code:
byte incoming = 0;
void setup() {
  Serial.begin(1200);
}
void loop() {
  if (Serial.available() > 0) {
    //Serial.print("Serial Available\t");
    incoming = Serial.read();
    Serial.println(incoming, DEC);
    //Serial.flush();
  }
  //Serial.println("Waiting");
}

and nothing happens. Nothing at all ever, at least not that I can see on the console. You see I have placed various little things I have tried for troubleshooting there after comment slashes. When I uncomment the "Waiting" code it will tell me it's waiting and print numbers. But the numbers don't look right (they are usually about 190 to 250 or so but vary randomly). So in case it was too fast, I tried increasing the transmitter code's loop delay to 100ms, but to no avail. So I set the system up to not have the USB cable plugged in (used a 9V battery for power instead), in case it's hogging the serial line somehow, and that doesn't seem to work either.

I've tried a bunch of troubleshooting tricks, too many to describe here up to and including Serial.write() instead of Serial.print(), and it still doesn't work as expected. I've looked through the forums and haven't seen what seemed to be a similar problem either.

Note that I unplug the serial wires before I load the program. And I do have a common ground between the two Arduinos (and even to the FTDI Basic breakout when I use it).

I'm hoping I'm just doing something silly and a more experienced person can straighten me out in an instant. We'll see. And thanks for your help.
8  Using Arduino / LEDs and Multiplexing / Re: External Interrupt "Multiplexer" on: August 11, 2011, 12:32:26 pm
I took a look at the XOR too, but then thought that it wouldn't help because it doesn't change state on the transition from 00 to 11 or 10 to 01.

HOWEVER, what are the chances of that?  In fact, on a quadrature encoder (or Gray code encoder for that matter), the chances are ZERO. So yeah, I guess the XOR gate actually does serve the purpose.

That just serves to remind me that theory and practice are different things. That is, the pure theory of my application (toggling an output on a state change of any one of several inputs) leads to a different solution when I take the real-life constraints of my inputs into account (in this case, that only one bit can change at a time).
9  Using Arduino / LEDs and Multiplexing / Re: External Interrupt "Multiplexer" on: August 11, 2011, 10:04:01 am
Excellent. Thanks! I was limiting myself to the basic core Arduino language and didn't know about pin change interrupts: http://arduino.cc/playground/Main/PcInt

That will solve the problem. As for the OR gate, I thought about that, but the problem is I need to trigger the interrupt not only on the change from 00 to 01, but also on the change from 01 to 11, or 11 to 10, and so on. I looked at the truth table for a bit and saw that I need a memory element like a flip flop because the new output turns out to be a function of the inputs and the previous output.

Anyway, it's all moot. ATMEL did something useful inside the chip and I don't need to worry about what that something was. Pin change interrupts it is!

Thanks
10  Using Arduino / LEDs and Multiplexing / External Interrupt "Multiplexer" on: August 10, 2011, 10:30:23 pm
Is there a straightforward way to have a state change on any one of several logic lines trigger a state change on a single pin?

Imagine, for example, that I have two quadrature encoders and want to connect them to an Arduino, which only has 2 external interrupts. (Even worse, my Ardumoto shield from Sparkfun uses one of those pins as a PWM output.) Anyway, it seems that I should be able to feed the pulses from all 4 lines to some sort of circuit which would then toggle its output when any of its inputs change. That way I only need one interrupt to call an ISR which then checks the state of four pins and calculates rotation. By the way, I may need the resolution provided by following all 4 transitions, so just interrupting on one of the quadrature lines might not do the trick.

It seems like the solution might be a cascade of flip flops. But I don't want to reinvent the wheel, as it were, if such a thing already exists. This can't be a novel concept, right?

I ran a few searches here and on the internet at large and did not find much. Perhaps I am using the wrong search terms.

Thanks for your help.
11  Forum 2005-2010 (read only) / Syntax & Programs / Re: Exponentially Weighted Moving Average Filter on: April 13, 2010, 03:39:42 pm
Excellent! Thanks!
12  Forum 2005-2010 (read only) / Syntax & Programs / Exponentially Weighted Moving Average Filter on: April 13, 2010, 02:45:38 pm
I'm working on implementing an Exponentially Weighted Moving Average Filter to clean up data from an accelerometer. It's pretty straightforward and efficient because I don't even need an array to store past values. And the filter's frequency response is nice and straightforward (first order low pass filter). All this matters for my application.

Here's the formula:

xbark = b*xbark-1 + (1-b)*xk

My only question is, can someone help me find out theoretically what the filter coefficient b does for the frequency response? I can see what it does in a general sense, but does anyone know how b (and of course my sample rate T) relate mathematically to the cutoff frequency of this filter? I can't really find it online and I don't remember enough of my signals and systems class to derive it from scratch. I heard that it was something like:

f = ln(b)/T

I need to know so that I can set my frequency response to an exact number by playing with b.

So yeah, this is not really an Arduino specific question, although I am programming it on an Arduino. Hopefully that's good enough. And thanks a lot for your help.
Pages: [1]