Netherlands
Offline
Newbie
Karma: 1
Posts: 30
|
 |
« on: January 11, 2013, 05:04:21 pm » |
Hey Arduinousers, We have an old can machine which uses a NRI G13.6000 (flat cable ribbon serial) as a coin acceptor. Now I need to trick the machines relays board to think that a payment has been made. The NRI has several output channels, but the one I need (channel 8) sends out a pulse to the board. I need to emulate that Pulse with the push of a button. This is the description of the output channel of the NRI: NPN 100ms 10mA active low w/ 47K pull-up to +5V Is there anyone who knows how to pull this off? Moderator edit: Smiley removed
|
|
|
|
« Last Edit: January 11, 2013, 05:12:44 pm by AWOL »
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 12
Posts: 327
The last thing you did is where you should start looking.
|
 |
« Reply #1 on: January 11, 2013, 05:08:18 pm » |
Do you want to learn to do it or do you want us to do it?
|
|
|
|
|
Logged
|
|
|
|
|
Netherlands
Offline
Newbie
Karma: 1
Posts: 30
|
 |
« Reply #2 on: January 11, 2013, 05:31:15 pm » |
Well even though it would be easier if someone did it, for me it would be better to learn it. I've come up with this code: void setup()
{
pinMode(10, OUTPUT); // PWM output right
}
void loop()
{
analogWrite(10, 56); // 56=111Hz ??
}
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 137
Posts: 19007
I don't think you connected the grounds, Dave.
|
 |
« Reply #3 on: January 11, 2013, 05:38:38 pm » |
// 56=111Hz I don't really understand that. PWM frequency is around 490Hz. There's no need to set the pinMode for an analogWrite
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Netherlands
Offline
Newbie
Karma: 1
Posts: 30
|
 |
« Reply #4 on: January 11, 2013, 05:39:55 pm » |
Yes and PWN is set between 0 and 255 right?
Zo 111Hz would be 56 value?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 137
Posts: 19007
I don't think you connected the grounds, Dave.
|
 |
« Reply #5 on: January 11, 2013, 05:41:58 pm » |
No, PWM frequency is fixed, you vary the duty cycle (mark:space ratio) with the parameter to analogWrite
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Netherlands
Offline
Newbie
Karma: 1
Posts: 30
|
 |
« Reply #6 on: January 11, 2013, 05:43:39 pm » |
Yep, but haven't I done that by giving analogWrite 56?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 137
Posts: 19007
I don't think you connected the grounds, Dave.
|
 |
« Reply #7 on: January 11, 2013, 05:46:55 pm » |
You have varied the duty cycle, but the frequency remains the same, namely 490 Hz.
I don't see the significance of this 111Hz from what you've said so far.
Edit. In case you don't understand the difference, consider a signal with one millisecond high, and nine milliseconds low. The frequency is 100Hz, and the duty cycle is 10%. A signal with nine milliseconds high and one millisecond low has the same frequency, but a 90% duty cycle.
|
|
|
|
« Last Edit: January 11, 2013, 05:56:39 pm by AWOL »
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Netherlands
Offline
Newbie
Karma: 1
Posts: 30
|
 |
« Reply #8 on: January 11, 2013, 05:53:12 pm » |
I've read the output from the coin acceptor.
It's 100Hz normally and when you insert a coin it drops to 90Hz for a few milliseconds.
So I need to emulate this behaviour, from what I've read, PWM output should be the way to go.
|
|
|
|
|
Logged
|
|
|
|
|
Netherlands
Offline
Newbie
Karma: 1
Posts: 30
|
 |
« Reply #9 on: January 11, 2013, 06:01:16 pm » |
What I've done to get the values: I've used pulseIn to read the pulse the coin acceptor generates: void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); pinMode(pin, INPUT); }
void loop() { duration = pulseIn(pin, HIGH); Serial.println(duration); delay(50); } It gives a long list of 9960 9899 9927 9932 9966 9892 And when I enter a euro (coin acceptor) it gives: 9928 10098 10124 9831
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 137
Posts: 19007
I don't think you connected the grounds, Dave.
|
 |
« Reply #10 on: January 11, 2013, 06:01:35 pm » |
No, PWM is not the answer. The PWM frequency is fixed unless you want to fiddle with registers. Using micros () may be much simpler. Have a look at blink without delay.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Netherlands
Offline
Newbie
Karma: 1
Posts: 30
|
 |
« Reply #11 on: January 11, 2013, 06:10:00 pm » |
So, normally I would have an interval of 9 milliseconds and on the push of a button it should need 10 milliseconds?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 137
Posts: 19007
I don't think you connected the grounds, Dave.
|
 |
« Reply #12 on: January 11, 2013, 06:12:34 pm » |
No, 9 milliseconds would be closer to 111Hz. 11 milliseconds would be roughly to 90Hz.
The relationship is a reciprocal.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Netherlands
Offline
Newbie
Karma: 1
Posts: 30
|
 |
« Reply #13 on: January 11, 2013, 06:18:50 pm » |
My pulseIn program gave the following values:
around 10124 microseconds when euro has been inserted around 9831 microsecond continuous so constant without euro.
So these are the values I have to use is 9.8 constant and then 10.12 when I insert a coin / push the button?
|
|
|
|
|
Logged
|
|
|
|
|
Netherlands
Offline
Newbie
Karma: 1
Posts: 30
|
 |
« Reply #14 on: January 11, 2013, 06:36:19 pm » |
As a side question, would it be possible to catch this on one pin (using pulsein) and then too just forward it to another pin with pulseout?
|
|
|
|
|
Logged
|
|
|
|
|
|