Show Posts
Pages: 1 [2] 3 4
16  Using Arduino / Programming Questions / Re: Arduino/CoinSlot/LCD - Variable Display. Need Help. on: January 09, 2013, 10:53:44 am
I am testing the code first that is why i have named them simply as "x", "y" and "z" variables.
Declaring these variables as volatile is just a precaution, but if it is unneeded then i'll simply remove it.

"CoinChange = 1" ; i forgot to delete that statement. i declared a "CoinChange" variable for a condition purpose but it is useless unless i can correct the problem of my code.

There is no problem with the connections of the devices. All is working properly.
What i want to display in the LCD is the 4 variables that counts the number of the coins and the total monetary of the coins inserted.
Type 1 coin (P1.00) = 1 pulse
Type 2 coin (P5.00) = 5 pulses
Type 3 coin (P10.00) = 10 pulses

Adding the total monetary is not a problem. The main concern is that i want to count the number of each type of coin that is inserted in the system.

With the code i shown, when i tested it, logically i was thinking with the delay at that start of the loop function the interrupt function would have had the time to count up the "coins" value before entering the main codes in the loop function.
The result is that it either counts right or:

~ Even when the total monetary counts up correctly to the corresponding type of coin, the Variable that corresponds to that coin doesn't count up.\
~ It counts up the wrong variable, most of the time it is the "x" variable, even when type 2 or type 3 is inserted in the coin slot.
~ It doens't count at all; the total monetary and any of the variables.

Ideally what i want is:
~ When i insert a Type 1 Coin, "x" variable counts up (x = x + 1), and total monetary counts up as well (a = a + 1)
~ When i insert a Type 2 Coin, "y" variable counts up (y = y + 1), and total monetary counts up as well (a = a + 5)
~ When i insert a Type 3 Coin, "z" variable counts up (z = z + 1), and total monetary counts up as well (a = a + 10)
17  Using Arduino / Programming Questions / Arduino/CoinSlot/LCD - Variable Display. Need Help. on: January 09, 2013, 09:46:52 am
Hi, need help on some programming problem.
I have already post a question about the interface of a coin acceptor to Arduino Uno,
http://arduino.cc/forum/index.php/topic,138209.msg1038645.html#msg1038645
and just wanted to repost and add another concern about the programming.

In the display, i want to display the Total of the Coins and the number of the coins inserted.
With this code i can't seem to get what i want to display.
x = number of Type 1 Coin
y = number of Type 2 Coin
z = number of Type 3 Coin
a = monetary total of the coins inserted

So here is my code:
Code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 6, 5, 4, 3);
volatile int coins = 0;
volatile int x = 0;
volatile int y = 0;
volatile int z = 0;
int a = 0;
void setup()
{
  lcd.begin(16, 2);
//CoinSlot
  EIFR = _BV (INTF0);
  pinMode(2,INPUT_PULLUP); 
  attachInterrupt(0, coinInserted, FALLING);
//CoinSlot
}
//CoinSlot
void coinInserted()
{
  coins = coins + 1;
  CoinChange = 1;
}
void loop()
{
  delay(1000);
  if(coins == 1){
    x = x + 1;
    a = a + 1;
  }
  else if (coins == 5){
    y = y + 1;
    a = a + 5;
  }
  else if (coins == 10){
    z = z + 1;
    a = a + 10;
  }
  lcd.setCursor(1,0);
  lcd.print(x);
  lcd.setCursor(4,0);
  lcd.print(y);
  lcd.setCursor(7,0);
  lcd.print(z);
  lcd.setCursor(1,1);
  lcd.print(a);
  coins = 0;
}

What happens is that i have setup 4 variables that will be displayed in the LCD. I was hoping that with the 1 second delay it would have given the interrupt function the time it needs to count up the "coins" variable before entering the Loop function. But as a result it either does count right or only counts up the "x" variable even when the i have use Type 2 or 3 coins.

Need HELP.
18  Using Arduino / General Electronics / Re: Power supply with Multiple Voltage Out ~ Help on: January 08, 2013, 09:11:44 pm
"As for turning it on, you just need to connect Pin 13 on the main connector (usually its green) to ground. That is a sense line so its very low voltage basically no current. You can even cut off the main PSU cable except for those two wires and put your power switch on that."

~ "As for turning it on"... turning on the computer PSU?
~ Connect Pin 13 and the main connector (usually green) to Ground?
19  Using Arduino / General Electronics / Re: Power supply with Multiple Voltage Out ~ Help on: January 08, 2013, 09:04:45 pm
~is it ok for the 5v o/p to supply 5 servo motors?

I haven't found any decent datasheet for the type of servo motor (TOWER PRO mg995)
that i''m using so i haven't found out yet how much amp is needed.
20  Using Arduino / Project Guidance / Re: Power supply with Multiple Voltage Out ~ Help on: January 08, 2013, 09:03:39 pm
"Must the 5Volts to be on separate o/ps?"

~ Vout3 to Vout7 will be used for 5 servo motors. I haven't found any decent datasheet for the type of servo motor (TOWER PRO mg995) that i''m using so i haven't found out yet how much amp is needed.
21  Using Arduino / Project Guidance / Power supply with Multiple Voltage Out ~ Help on: January 08, 2013, 08:47:25 pm
Hi... I'm working on a design and i'm having a problem with how i can make a power supply for it.
Mainly this what I want to do:

Vin = 220v
~
Vout 1 = 7v
Vout 2 = 12v
Vout 3 to Vout 7 = 5v

Can anyone help on how i can make this?

Vout1 is for Arduino. Vout2 is for a coin acceptor. Vout3 to Vout7 would be used for servo motors (tower pro mg995)
22  Using Arduino / General Electronics / Power supply with Multiple Voltage Out ~ Help on: January 08, 2013, 08:46:04 pm
Hi... I'm working on a design and i'm having a problem with how i can make a power supply for it.
Mainly this what I want to do:

Vin = 220v
~
Vout 1 = 7v
Vout 2 = 12v
Vout 3 to Vout 7 = 5v

Can anyone help on how i can make this?

Vout1 is for Arduino. Vout2 is for a coin acceptor. Vout3 to Vout7 would be used for servo motors (tower pro mg995)
23  Using Arduino / Programming Questions / Re: Pulse Reading from Coin slot to Arduino on: December 19, 2012, 07:02:23 pm
THANK YOU SO MUCH for the suggestions/advice/comments.
This is the code now:
Code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 6, 5, 4, 3);
volatile int coins = 0;

void setup()
{
  lcd.begin(16, 2);
  pinMode (2,INPUT_PULLUP);
  attachInterrupt(0, coinInserted, FALLING);
}
void coinInserted()
{
  coins = coins + 1;
}
void loop()
{
  lcd.setCursor(1,0);
  lcd.print(coins);
}

On the LCD display, when i turn on the Arduino and the Coin Slot, it displays 1 and not 0 so i assume it already read a pulse when turned on, but still it counts the way i need it to count. It doesn't count up continuously anymore, and counts up respectively to what coin is inserted. Still starting from 0 and not 1 would be a bit more of a convenience to me than finding a way to get rid of the unnecessary 1 on start. Thanks for the Help!  smiley-lol
24  Using Arduino / Programming Questions / Re: Pulse Reading from Coin slot to Arduino on: December 19, 2012, 06:21:09 pm
Just a Quick Question about Arduino...
If i'm using PIN 2 as Interrupt pin, does the required voltage, being above 3V is HIGH and below 3V is LOW, still a necessity?
25  Using Arduino / Programming Questions / Re: Pulse Reading from Coin slot to Arduino on: December 19, 2012, 10:58:18 am
As another checking if there really is a change in the pulsing in the signal wire, w/ a circuit inbetween the signal wire (the wire that gives supposedly a pulse signal) to the arduino, i have connected a LED in between.

With or w/out this circuit in between THEY HAVE THE SAME RESULT.

the thing is as i turned on the coin slot and the arduino, as well as the LCD and all of them being connected, the LED in the circuit is continuously lit up. As I inserted the a coin it shows a change and blinks:
When P1.00 coin is inserted, it blinks once.
When P5.00 coin is inserted, it blinks 4 times.
When P10.00 coin is inserted, it blinks 8 times.



26  Using Arduino / Programming Questions / Re: Pulse Reading from Coin slot to Arduino on: December 19, 2012, 09:01:22 am
Yes i am certain that it is one of the fixed products.
27  Using Arduino / Programming Questions / Re: Pulse Reading from Coin slot to Arduino on: December 19, 2012, 08:32:42 am
http://e-gizmo.com/wordpress/?p=895
The vendor explained briefly what output is generated when coins are inserted.
28  Using Arduino / Programming Questions / Re: Pulse Reading from Coin slot to Arduino on: December 19, 2012, 08:21:38 am
I have been searching but i haven't found any link for the datasheet of the coin acceptor. As i explained i tested using "CHANGE", "FALLING", "RISING", and "LOW" and described what output i got. I'm sure that i connected the correct line to digital pin 2 to read the pulse from the coin slot.

http://e-gizmo.com/wordpress/?p=895

i double checked the connections and i'm sure that the ground of the Arduino, Coin Slot, and LCD are all connected. I also checked the voltage supplies of the LCD and the Coin slot (5V and 12V respectively) and i'm sure its right.
29  Using Arduino / Programming Questions / Pulse Reading from Coin slot to Arduino on: December 19, 2012, 07:31:43 am
Hey Guys really need your help on how to accurately read the pulse signal input from a Coin Slot to Arduino Uno
This is the code i used:
Code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 6, 5, 4, 3);
volatile int coins = 0;

void setup()
{
  lcd.begin(16, 2);
  Serial.begin(9600);
  attachInterrupt(0, coinInserted, CHANGE );
}
void coinInserted()
{
//delay(1000);
  coins = coins + 1;
}
void loop()
{
  lcd.setCursor(1,0);
  lcd.print(coins);
}

the coin slot has been set for 3 outputs:
P1.00 coin- 1 pulse
P5.00 coin- 5 pulse
P10.00 coin- 10 pulse

I used a LCD to see if the "coins" value counts corresponding to the coin inserted. But when i started to test,
the LCD DISPLAYS A CONTINUES COUNT OF THE "coins" VALUE EVEN WHEN I HAVEN'T EVEN INSERTED A COIN IN THE COIN SLOT.

In the attachInterrupt command, i interchange the "CHANGE", "LOW", "RISING", and "FALLING" and here what happens:
Falling: with delay set to 5000 - 50000, even without a coin inserted it counts up but more slowly
Rising: the same as Falling
Change: the same as Falling and Rising
Low: with delay set to 5000 - 50000, after uploading the program code to arduino the LCD doesn't display anything. Without any delay and after uploading the program code the LCD displays a continues count up of the "coins" value insanely fast.

What i'm after:
If I inserted a coin, (1,5 or 10), the LCD should display from "0" to the corresponding count up of pulses being read by the arduino (0 to 1, 0 to 5, 0 to 10) and continues to count up depending on the coin being inserted.

REALLY NEED HELP ON FIXING THIS PROBLEM.


30  Using Arduino / Motors, Mechanics, and Power / Re: Coin segregation using motors - need help on: November 26, 2012, 09:58:38 pm
Thanks for the replies/comments/suggestions. I would like to do it mechanically but there is a limit to the number of coins inserted and any further coins inserted in the system will be moved to an extra case. If using the first design what will happen is if the specified number of coins has been reached for each type of coin the slots will not open, guiding the extra inserted coins down to an extra case. Our currency has 3 Types of Coins, hence the 4 pathways in the second design.

Thanks! smiley-grin
If you have any other comments please do post smiley
Pages: 1 [2] 3 4