Show Posts
Pages: 1 2 [3] 4 5 ... 22
31  Using Arduino / Programming Questions / Re: 3x 74HC165, one of them not working on: February 17, 2014, 01:34:34 pm
i think this   should be a  bad 74hc165 and/or bad software?
Alternative 3: Wiring error.  If I had to speculate, based on what you've told us so far, I'd guess that the LOAD signal isn't getting to your third IC.  That would mean that the IC would never get new data, but it would dutifully shift out its powerup value.  That might be 0xFF.  A way to test that might be to program the Arduino to toggle the LOAD pin low for several seconds, and then high for several seconds.  You should be able to see it on a voltmeter.  If there's no voltmeter, you could hook up an LED and resistor, or set pin 13 to INPUT and run a jumper from LOAD to pin 13 and watch the on-board LED.

I think that this
Quote
swapping the ICs around, even using a new set of 3 74HC165 and 4 mc14490, gives same results.
argues against the theory that one of the 165's is broken.  The problem follows the location in the circuit, rather than the specific IC, suggesting that it's a software problem - like something being an int that should be a long - or a wiring problem - like some signal isn't going where you think it does.

Another possibility for this error might be a bad ground for some of your switches.  We can't tell how they're wired - they might be hooked up in groups of eight.  One way to test this is to look at the 14490's output pin voltages relative to ground, and observe that they change.

Quote
removing the debouncers is a complete chaos (everything constantly fluctuating...)
Can you clarify that?  Do you mean that the outputs change even when the inputs are stable, or do you mean that changing an input results in many changes in the output?  When you removed the 14490's, did you reconnect the switches directly to the 165, or did you leave the 165's input pins open-circuited? 

Quote
from my pov there is something wrong with the software
Maybe.  Your symptoms - failure to register changes on the highest of three bytes of data - suggest that the data passes through some storage location that's only 16 bits wide, making the high-order byte disappear.  A cursory look through your code doesn't find that, though.  I'm favoring a wiring error.
32  Using Arduino / Programming Questions / Re: 3x 74HC165, one of them not working on: February 16, 2014, 10:09:13 pm
You may want to check your hardware design.  It looks like the notes in the schematic say these two things:
  • You're grounding the 14490 inputs through a 10K resistor.  The 14490's have an internal pullup resistor; they're intended to be driven by an active input, or grounded directly.  When the switch is closed, the 10K resistor keeps the input voltage close to the worst-case VIL of the 14490, 1.5V at VDD=5V.  A 14490, or more than one, might not be able to see a low input at that voltage.
  • The Q'H outputs of the 74HC165's are grounded.  Q'H - pin 7 - is an output on the 74HC165; if it's not used, it should be open, not grounded.  Maybe that's a typographical error?
33  Using Arduino / Programming Questions / Re: Pin and timer interrupt in same program on: February 16, 2014, 06:16:06 pm
When I run this code, it works erratically.  Sometimes the watchdog is clearly waking the processor, and sometimes it's clearly not.  Sometimes it fails for a while, and then after an INT0, it starts working again.  

Here's what I think is happening:  You're using some kind of mechanical connection - a switch or a wire - to simulate INT0.  I think it gives you multiple INT0 interrupts as the contact or wire bounces.  One of those interrupts interferes with the action of putting the processor to sleep.  Here are my favorite suspects:

In function myWatchdogEnable(), I think that these bits of code shouldn't be interrupted:
Code:
     WDTCSR |= 0b00011000;               // see docs, set WDCE, WDE
      WDTCSR =  0b01000000 | interval;    // set WDIE, and appropriate delay
and
Code:
     MCUCR = bit (BODS) | bit (BODSE);
      MCUCR = bit (BODS);
Each of those snippets set a special "change enable bit," and the new register data must be written before some small number of cycles elapses.  I believe that those should be wrapped with interrupt disable and enable instructions.

Before the processor sleeps, it needs to attach the INT0 interrupt, and enable interrupts.  Otherwise, it can't respond to interrupts, or INT0 in particular, while sleeping.  But, once interrupts are enabled, the program will respond to a pending INT0 interrupt.  That'll call wake(), which will disable the watchdog and return, and the processor will go to sleep with the watchdog disabled.  The processor promises to execute one instruction after interrupts are enabled, before responding to an interrupt.  For this to work, that next instruction should put the processor to sleep.

The instruction "sleep_mode()" is a macro that calls three other macros: sleep_enable(), sleep_cpu, and sleep_disable().  sleep_enable() and sleep_disable() are macros that execute several machine instructions, and sleep_cpu() is a macro that executes a single machine instruction, "SLEEP."  If you use sleep_mode(), the instruction that comes immediately after interrupts are reenabled will be some part of sleep_enable(), and then a pending interrupt will be acknowledged, the watchdog timer will be disabled, execution will return to finish sleep_enable(), and the processor will go to sleep with the watchdog disabled.  I think that you want to explicitly call those macros, and the last thing that happens after interrupts are reenabled should be sleep_cpu().

When I collected the time-critical register settings together with attaching interrupt 0, disabled interrupts while they execute, and used this code to put the processor to sleep:
Code:
sleep_enable();
interrupts();  //  [Edit: Added this.]
sleep_cpu();  //  [Edit: Fixed this]
sleep_disable();
it worked reliably.  That is to say, I couldn't get it to fail in a reasonable number of tries.  If you want the code, I'll post it; my guess is that you'd prefer to hammer it out yourself.
34  Using Arduino / Project Guidance / Re: Arduino cat feeder on: February 14, 2014, 01:21:52 am
A wiser man than I would avoid this thread, since I've never driven a motor with an Arduino, and I've never experimented with power reduction with an AVR.  But, this project has two of my favorite things:  cats and Eneloops.  I'm in.

Nick Gammon has posted some excellent-looking information about power conservation with the Arduino.  You can see it here:  http://www.gammon.com.au/forum/?id=11497.  To get really low power, you'll need to construct something without the power LED, and some of the other stuff.  You might be happiest using a through-hole ATMega328P in a socket, because you can remove it and program it in your Arduino.

I think that 3 or 4 AA's might be the right choice.  With 4 in series, the output could be 1.4V per cell, or 5.6V, a bit above the recommended operating voltage for the ATMega's, but below the absolute maximum rating of 6.0V.  You won't be able to substitute alkalines at nominal 1.5V, though, since fresh batteries will probably exceed 6.0V.  With 3 batteries, there's no danger of overvoltage, and you can use alkalines in a pinch, but a low voltage of 3.0 to 3.3 volts with old NiMH's could limit your motor choices.

Four AA's will give you a nominal voltage of 5V, with an end-of-discharge voltage of about 4.0 to 4.4V, depending on where you call them, "dead."  You can operate at 16 MHz over that range, but you might want to select something lower for to keep power usage down.  

Eneloops are rated at 2000 mA-hours by their manufacturer, whoever that is just now.  I'll guess that a geared motor will draw 500 mA for ten seconds for each feed, and that you'll be able to get the average microcontroller current down to, say, 2 mA.  The motor will take about 1.4 mAh per day, and the micro will take 48, for about 50 mAh per day, or a life of maybe twenty days.  Call it two weeks, conservatively.

For control, I envision a single button that means, "Feed in X hours."  X might 24, so you can feed today and get four more feedings at the same time of day, or it might be 4 or 5, so you can start it before work and feed around noon.  I don't see a need to debounce it.  What's a few milliseconds to a cat?  Alternatively, you can add a two-digit display that shows you how many hours until the next feeding, and set it to something between 1 and 24 with a button.  

... what breed is an Arduino Cat?
A cat that performs directed tasks?  Never seen one.
35  Using Arduino / Project Guidance / Re: Need some guidance on a medical device design project, Arduino noob on: February 13, 2014, 08:31:43 pm
The OP doesn't say it's an academic effort; we've inferred that, and we might be wrong.  Maybe it's an academic, or veterinary, or even agricultural project.  If it's never going to be involved in human patient care, the OP can say so, and anyone can decide whether to participate.  For now, I'm presuming that the term, "medical device," means, well, a medical device.  It wouldn't be the first time on this forum:  http://forum.arduino.cc/index.php?topic=180658.0.

If it's intended to perform a medical-ish function, like pulse rate measurement, on healthy people able to care for themselves, I'd still seriously recommend that it be battery-powered.  I'm against the notion of attaching anything to a human that relies on the isolation of a cheap wall-wart.
36  Using Arduino / General Electronics / Re: I need help with this amplifier power supply! (dual rail) on: February 13, 2014, 12:29:10 pm
What voltages are you measuring?  With a center-tapped transformer, I'd expect you to measure voltage between the transformer's center tap and the DC outputs, to read something like +18V and -18V.  If the transformer isn't center-tapped, what points are you measuring between?

I think we need a schematic, with the measurement points indicated.
37  Using Arduino / Project Guidance / Re: Need some guidance on a medical device design project, Arduino noob on: February 12, 2014, 07:04:27 pm
I'm working on a project for a medical device ...
I have no clue where to start ...
That's a real good reason to refrain from trying to make a medical device.
Quote
Any input or guidance would be GREATLY appreciated.
Here's input:  Medical devices should be designed by people skilled in the art, they should be extensively tested, and they should be listed for their purpose.  They shouldn't be designed by people who "have no clue."

Here's guidance:  DO NOT ATTEMPT.

Now, maybe when you say, "medical device," you're talking about a device that monitors your brain waves, determines whether you want pizza or Chinese takeout, and orders it online.  If that, or something like it, is what you contemplate, say so.
38  Using Arduino / Programming Questions / Re: 20Hz Square Wave on the Uno on: February 11, 2014, 01:00:51 am
Using the Original Poster's code as posted, I got an excellent 20Hz signal from pin 9.  I don't know what didn't work.

TimerOne uses the Phase and Frequency Correct mode, in which the centers of the output pulses are separated by the signal period. It's possible that the treadmill motor is so sensitive that it doesn't like that signal, and would prefer to see the rising edges of the signals separated by the signal period.  That would be sensitive indeed, for a gizmo like this.

What went wrong using this code?

Review my posts from yesterday ...
I think it's this one: http://forum.arduino.cc/index.php?topic=216827.msg1585074#msg1585074.  That technique allows for a constant leading-edge-to-leading-edge period.
39  Using Arduino / Programming Questions / Re: 20Hz Square Wave on the Uno on: February 10, 2014, 08:26:21 pm
... need to generate a 20Hz square wave in which I can adjust the duty cycle... 
... tried using the Timer1 library ...
I think that the TimerOne library will support a very nice 20Hz square wave, with a variable duty cycle, and a resolution of one part in 1024.
Quote
If you need any additional information, I can supply it.
Please supply it.
  • Did you use the TimerOne library accessible from this page: http://playground.arduino.cc/Code/Timer1 ?  If not, you'll want to include a link that points to the library you used.
  • What did you try?  Post code, please, using code tags.
  • What did you expect it to do?
  • What did it do?

40  Using Arduino / Programming Questions / Re: Compile two sketches on: February 07, 2014, 11:24:07 am
... you mean i should just compile every functions i want?
Compile?  No, I was talking about troubleshooting connections.  I recommend compiling the only the code that you need to test the parts of the project that you're investigating.  So far, you're not at a point where it makes any sense to do anything with the servo at all.

I'll summarize what I think you've said:
  • You've connected the LCD to the Arduino via the breadboard.
  • You've disconnected everything else.
  • The LCD works the way you think it should work.
Is that correct?

Next you mention a "sensor shield."  I don't know what that is.  Is that the device that connects to the servo?

You also mention that connecting the voltage pin of the "sensor shield" to 5V on the breadboard makes the LCD fail.  I presume that the "voltage pin" is the power input for that device.  Here's what I recommend:
  • Verify that you're connecting the correct pin from the "sensor shield" to 5V.  Check the datasheet and be sure.
  • Verify that the pin on the breadboard that you think is 5V is really 5V.
  • If those are correct, figure out how much current the "sensor shield" requires.  Check the datasheet and be sure.
  • If you have a voltmeter, connect the "voltage pin" of the "sensor shield" and measure the voltage on the Arduino's 5V.  Verify that it's close to 5V.
Please tell us what you find.

The "sensor shield" may be drawing too much current from the Arduino 5V supply, and causing it to fail.  Since that same 5V supply presumably powers the LCD, that would make it fail, too.  It should also interfere with the Arduino's function.  So, try this, too:
  • Add Serial.println() statements to print everything that you print to the LCD to the serial monitor, too.
That'll tell you if the Arduino is functioning at all.  Please tell us what you see on the serial monitor, and post your code.

There's nothing in your program that verifies that the Arduino is working at all.  If it can send the expected data to the serial monitor, that will give us some confidence in the 5V power supply.  If it can't, that tells us that something's happening to the Arduino, and changing your code won't fix it.

Let us know what you find.
41  Using Arduino / Programming Questions / Re: Compile two sketches on: February 07, 2014, 09:54:02 am
Wiring error? Mind to explain?
Here's what I think you said:
  • When you wire directly between the Arduino and the LCD, the LCD works. 
  • When you wire from the Arduino to a breadboard, and then from the breadboard to the LCD, the LCD doesn't work.
So, it appears that having the breadboard between the Arduino and the LCD causes something to fail.  I think that the most likely reason for that failure is that the connections aren't made correctly at the breadboard.  I think it's likely that some wires have been interchanged, or that some of the wires aren't making good connections.

[/quote]... I'm trying to simplify by routing them first.[/quote]Based on the photograph attached to reply #14, things don't look all that simple.  I'd recommend connecting directly to the LCD and getting it to work.  Than, reconnect one wire at a time via the breadboard, and test after reconnecting each wire.  That way, it will be quite easy to see which connection is wrong.  It may seem tedious, but it'll certainly be less tedious, and more likely to yield success, than hooking it up, watching it fail, and posting, "Any ideas?"
42  Using Arduino / Programming Questions / Re: Compile two sketches on: February 07, 2014, 08:18:11 am
,,, plugged the LCD Keypad Shield straight to the board. It works perfectly ,,, when i rejoin them back to the breadboard, it can't function again ... Any idea?
My first guess: wiring error.

Are you routing connections between the Arduino and the LCD via the breadboard?  Can you tell us why?
43  Using Arduino / Programming Questions / Re: Compile two sketches on: February 05, 2014, 10:39:18 am
What does it do?
What did you expect it do do?
Did either of the two sketches work before you combined them?
44  Using Arduino / Programming Questions / Re: Timer faster than it should be. on: February 02, 2014, 03:15:30 pm
It looks like this problem is largely peculiar to the Arduino IDE.  After a reset, the timers are in "Normal" mode, with the OCRnx registers unbuffered; changes to the OCR registers take immediate effect.  Under the Arduino IDE, the timers are in a PWM mode, with the OCRnx registers double-buffered when we get control of them; changes to those registers pend until the timer hits one or the other of its limits.  Users of some other means of programming an Arduino may never see this problem, whether or not they set the registers in the "logical order."  It might come up if a program used a double-buffered PWM mode, and then switched to an unbuffered mode, but that may be an infrequent usage.

Here's a link to a similar discussion among the AVRfreaks, from just a week or two ago:  http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=139619

Tests with the original sketch in this thread showed that TCNT2 never varied from zero, consistent with OCR2A being set to 0 in the CTC mode.  At the same time, OCR2A reported a value of 249.  It looks like the buffered value was reported, while the active value was something different.  I don't find this mentioned in the datasheet.  It says,
Quote
The OCR2x Register access may seem complex, but this is not case. When the double buffering is enabled, the CPU has access to the OCR2x Buffer Register, and if double buffering is disabled the CPU will access the OCR2x directly.
It looks like write access in CTC mode is direct, and read access isn't.  I'm inclined to call this an "undocumented feature." 
45  Using Arduino / Audio / Re: Complex Waveform Tables on: January 31, 2014, 01:22:36 am
There's an archive of musical instrument samples at this site:  http://theremin.music.uiowa.edu/MIS.html.  It covers most of the orchestra, along with guitar and a few other instruments, and even has balloons popping and sticks banging together.

A brief look at a few directories says that these are aiff files, and some of them are very large.  A closer look at a couple of files finds a 96kHz sample rate, and a lot of subaudible noise.  I would imagine that there's substantial effort between these files and the sets of samples that you want.  But, the data exist, and are available free.

[Edit: Spelling]
Pages: 1 2 [3] 4 5 ... 22