Show Posts
Pages: [1] 2
1  Using Arduino / Programming Questions / Re: help with math on: January 17, 2013, 03:49:52 pm
It would be much easier to help you if you posted the code, or at least gave some sample inputs and outputs.  Otherwise we are just guessing at what the problem is.

One thing is that to preserve accuracy, you need to re-arrange the calculation a little.  Also, if you want unsigned long results, you should use unsigned long constants and variables in the calculation as much as possible.

Code:
delay = 1000UL * (m * 60UL)) + s) / (passes * 49);


it works! thank a lot!!
2  Using Arduino / Programming Questions / Re: help with math on: January 17, 2013, 03:22:02 pm
furthermore the speed of a swimmer is not constant near the turning points and when it starts. Also the speed tends to slow down as the swimmer gets more acid in his /her legs and arms.
==> one delay will not work.


this project is to swimmer learn to keep constant speed all the time. I'm not a trainer, I'm just a one who want to help kids in local swimming club. They ask me to do it and I'm trying to  smiley-roll
3  Using Arduino / Programming Questions / Re: help with math on: January 17, 2013, 02:15:27 pm
It would be much easier to help you if you posted the code, or at least gave some sample inputs and outputs.  Otherwise we are just guessing at what the problem is.

One thing is that to preserve accuracy, you need to re-arrange the calculation a little.  Also, if you want unsigned long results, you should use unsigned long constants and variables in the calculation as much as possible.

Code:
delay = 1000UL * (m * 60UL)) + s) / (passes * 49);


what is UL?

here is part od code:
Code:
#include <SoftwareSerial.h>

SoftwareSerial ser(2,3);

//Pin connected to latch pin (ST_CP) of 74HC595
const int latchPin = 8;
//Pin connected to clock pin (SH_CP) of 74HC595
const int clockPin = 12;
////Pin connected to Data in (DS) of 74HC595
const int dataPin = 11;
//Pin connected to data of third 595
const int dataPin2 =6;
byte pass=1;
unsigned long int wait= 500;

void setup() {
  ser.begin(19200);
  delay(100);
  //set pins to output because they are addressed in the main loop
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT); 
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin2, OUTPUT);
}

void loop() {
 
 
  //unos podataka
  ser.print("\eO770;1000~");//start beep



ser.print('\f'); 
ser.println("50m :"); //number of pass
response=get_int(); // Get an integer number from phi-panel
int pass=response;
ser.print('\f');
ser.println("Metars:");
ser.print(pass*50);
ser.print(" m");
delay(1000);

ser.print('\f'); 
ser.println("Enter minutes:"); //minutes
response=get_int(); // Get an integer number from phi-panel
int minutes=response;
ser.print('\f');
ser.print(minutes);
ser.print(" minutes");
delay(1000);

ser.print('\f');
ser.println("Enter seconds:"); // seconds
response=get_int();
int sec=response;
ser.print('\f');
ser.print(sec);
ser.println(" seconds");
delay(1000);


 
wait=(((minutes*60)+sec)*1000)/(49*pass); //calculation of delay
 
4  Using Arduino / Programming Questions / Re: help with math on: January 17, 2013, 02:03:39 pm
You say you have 25 LEDs.... Surely in a 25m pool you would have either 26 LEDs (if there are LEDs at the very ends) or 24 LEDs?

 smiley-eek upps, you're right. I must have 26 led's!! So, passes must be multiplied with 51  smiley-mr-green
thanks for suggestion, I will notice my mistake after build 25 meters of led strip  smiley-sad
5  Using Arduino / Programming Questions / help with math on: January 17, 2013, 11:02:31 am
Hi everyone,
I have developed project for help swimmers to train better. It consist of 25 led's in pool bottom(each meter is one led) and they are lit in programmed time. I have developed input via liudr and led output via 74hc595. It works nice, but I can't make arduino to calculate right time for delay between led's.
There is a few variables that operator enter via keyboard: number of 50m passes of pool (integer, can be byte), pass time in minutes (it is easy to enter separately minutes then seconds) and seconds. Goal is to calculate time for delay. I think formula be like this: delay= ((minutes*60)+seconds)/(number of pass*49)*1000. why 49 and not 50? because it will be used in 25m long swimming pool and after 25 led is lit then 24...1 led is lit. So one led must be subtracted from every 50m pass.
When I enter formula like that in my program (delay is long unsigned integer) I don't have proper calculation. I have tried with float but this also don't work. Can somebody tell me how to calculate that delay ?
6  Using Arduino / Project Guidance / Re: how to drive 25 led with 5 pcs of 595 shift register? on: November 16, 2012, 07:02:55 am

You can either slow it down or you can use buffers.

Both are very simple.


can you direct me how? with some link maybe?
7  Using Arduino / Project Guidance / Re: how to drive 25 led with 5 pcs of 595 shift register? on: November 16, 2012, 04:51:23 am
I'd select quite a low clock frequency in the first instance
how to do that?
8  Using Arduino / Project Guidance / Re: how to drive 25 led with 5 pcs of 595 shift register? on: November 16, 2012, 04:50:56 am
I think you want a little bit of logic at each LED.
Have a little 8-pin uC every meter to control the LED and minimizethe wiring in the tube.

This is possible solution if 595 failed. But this will cost a much more than 4 595 chips + lots of wire, so I will firs try cheaper solution. Thank for your advice and time!  smiley
9  Using Arduino / Project Guidance / Re: how to drive 25 led with 5 pcs of 595 shift register? on: November 15, 2012, 02:53:28 pm
SPI is just another serial clocked protocol, same issues.  Some of the LED driver chips have schmitt trigger clock inputs specifically to help with long signal runs.   You are using good decoupling aren't you?  22uF or more at each shift register is a start.

There is Charlieplexing - 25 LEDs would take 6 wires and 6 resistors, but you get a reduction in brightness due to multiplexing.
For now all is on breadboard so I don't use any decoupling for now. First I want to make all 25 led running as I expect. After that I will be making a long version and solve problems.
Charlieplexing use too many pins from arduino and it is complicated to cross wires in the tube.
10  Using Arduino / Project Guidance / Re: how to drive 25 led with 5 pcs of 595 shift register? on: November 15, 2012, 01:38:30 pm
You will likely have trouble sending clock and data along long cables like that unless at a low data rate.  Logic signals degrade over a few feet / metres and can lead to crosstalk, spurious glitches etc (remember these signals have rise and fall times of a few nanoseconds).  I'd select quite a low clock frequency in the first instance, say 10kHz or so, and add 100 ohm resistors in-line before the inputs to each 595 (suppresses reflections).  You may still have problems - experiment with one '595 and set of LEDs first.

More advanced cures are adding an RC low-pass filter and a schmitt trigger gate to clean up the edges.
I still have trouble to make more than 16 leds to move. This is first problem  smiley-sad
Second, there is a possible problem with a long wires. smiley-sad
Is there another way beside 595 to control 25 leds with just few wires? somebody mentioned SPI control
11  Using Arduino / Project Guidance / Re: how to drive 25 led with 5 pcs of 595 shift register? on: November 15, 2012, 12:55:34 pm
You have proper decoupling on all these 595's and a powerful enough power supply?  There shouldn't be problems daisy-chaining them upto 10 or so (so long as all wiring is short).  For 25 LEDs you only need 4 shift registers.

wires will be long, one led at one meter. 595 will be at every 8 led + transistor for driving led. All this will be in transparent tube and immerse in swimming pool.
Is there another way to control this 25 led's, maybe with even less wires from tube to controller with arduino
12  Using Arduino / Project Guidance / Re: how to drive 25 led with 5 pcs of 595 shift register? on: November 15, 2012, 12:51:44 pm
Double the hardware chain, call this twice? Make it just 9 vs 16.
Code:
 int bitToSet = 0;

  // write to the shift register with the correct bit set high:
  for (bitToSet=0; bitToSet<16; bitToSet++){
    registerWrite(bitToSet, HIGH);
  delay(300);
}

I use another arduino pin for additional two 595 data line. clock and latch are connected to same arduino pins as first pair of 595.
add slightly changed registerWrite to sketch and IT'S ALIVE!  smiley-mr-green 
25 led goes like the way I wanted! Thanks for direction!
13  Using Arduino / Project Guidance / how to drive 25 led with 5 pcs of 595 shift register? on: November 14, 2012, 05:39:57 pm
Hi,
I need to control 25 led's, one after another. Everything is fine with 2x 595 and 16 leds, but I don't know how to add another 3x 595 and rest of led's  smiley-confuse
When I add third 595 it light up all led's connected to it after last led in second 595.

Code:
/*

 Created 23 Mar 2010
 by Tom Igoe

 */

//Pin connected to latch pin (ST_CP) of 74HC595
const int latchPin = 8;
//Pin connected to clock pin (SH_CP) of 74HC595
const int clockPin = 12;
////Pin connected to Data in (DS) of 74HC595
const int dataPin = 11;

void setup() {
  //set pins to output because they are addressed in the main loop
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT); 
  pinMode(clockPin, OUTPUT);

}

void loop() {
 
    int bitToSet = 0;

  // write to the shift register with the correct bit set high:
  for (bitToSet=0; bitToSet<16; bitToSet++){
    registerWrite(bitToSet, HIGH);
  delay(300);
}
 
}

// This method sends bits to the shift register:

void registerWrite(int whichPin, int whichState) {
// the bits you want to send
  unsigned int bitsToSend = 0;

  // turn off the output so the pins don't light up
  // while you're shifting bits:
  digitalWrite(latchPin, LOW);

  // turn on the next highest bit in bitsToSend:
  bitWrite(bitsToSend, whichPin, whichState);

  // break the bits into two bytes, one for
  // the first register and one for the second:
  byte registerOne = highByte(bitsToSend);
  byte registerTwo = lowByte(bitsToSend);

  // shift the bytes out:
  shiftOut(dataPin, clockPin, MSBFIRST, registerOne);
  shiftOut(dataPin, clockPin, MSBFIRST, registerTwo);
 
    // turn on the output so the LEDs can light up:
  digitalWrite(latchPin, HIGH);

}
14  Using Arduino / Project Guidance / Re: LCD and matrix keyboard - which library? on: November 07, 2012, 09:40:48 am
Paul,

Thanks for mentioning me.

flega,

What about this thing?

http://www.inmojo.com/store/liudr-arduino-and-physics-gadgets/item/serial-lcd-back-pack---phi-panel/

It is the easiest to program with since you need no library, just do serial.print and serial.read. Both LCD and keypad are connected to the back pack. There are many sample projects for inputting numbers and etc. available.

I think this is right thing for me! I have read most stuff on your blog and this is really good work, not expensive too. It is best that it use only two pins on arduino and no memory. I'll buy it today!
15  Using Arduino / Project Guidance / Re: LCD and matrix keyboard - which library? on: November 06, 2012, 04:45:04 pm
example what operator must do:
a text on LCD is written "Total swimmer time"
After a second "enter minutes"
operator push one or two buttons on keyboard and numbers are displayed on LCD. Arduino waits for * button to continue or # button to erase a wrong entered number.
After that display shows "enter seconds" and same procedure as before. It will be even better if operator can enter minutes and seconds in format MM:SS and arduino can receive that.
How can I program that ?
Pages: [1] 2