Welcome Guest! To enable all features please Login or Register.
Options
Go to last post Go to first unread
juhapekka.seppala@saunalahti.fi  
#1 Posted : Tuesday, June 30, 2015 5:39:34 AM(UTC)
juhapekka.seppala@saunalahti.fi

Rank: Member

Groups: BetaUser, Registered
Joined: 6/4/2015(UTC)
Posts: 24

Hi
I have infrared receiver connected to arduino uno's digital input.
When remote control button is pressed ir-receiver detect/send's ab 34 pulses/70 milliseconds to uno's input (checked with oscilloscope). Simple pulse counter program made with Embrio detects only ab. 3 pulses/70 milliseconds. What i am doing wrong? Confused
EmbrioAdmin  
#2 Posted : Tuesday, June 30, 2015 5:41:53 AM(UTC)
EmbrioAdmin

Rank: Administration

Groups: Administrators
Joined: 12/11/2014(UTC)
Posts: 661

Thanks: 1 times
Was thanked: 81 time(s) in 76 post(s)
Not sure. Could you zip up the project and email it to ezra@embrio.io? I can take a look at it tonight.
juhapekka.seppala@saunalahti.fi  
#3 Posted : Tuesday, June 30, 2015 8:57:58 PM(UTC)
juhapekka.seppala@saunalahti.fi

Rank: Member

Groups: BetaUser, Registered
Joined: 6/4/2015(UTC)
Posts: 24

Hi
I will try zipping Glare.
Result is same program with 2 nodes.
Digital input node connected to digital output node.
IR receiver in input and Oscilloscope in output.


I tried also with IDE sketch (same uno board).

int ledPin = 13; // LED connected to digital pin 13
int inPin = 7; // pushbutton connected to digital pin 7
int val = 0; // variable to store the read value

void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin 13 as output
pinMode(inPin, INPUT); // sets the digital pin 7 as input
}

void loop()
{
val = digitalRead(inPin); // read the input pin
digitalWrite(ledPin, val); // sets the LED to the button's value
}


IDE program works OK. (34pulses/70 milliseconds in output)
EmbrioAdmin  
#4 Posted : Wednesday, July 01, 2015 2:36:47 AM(UTC)
EmbrioAdmin

Rank: Administration

Groups: Administrators
Joined: 12/11/2014(UTC)
Posts: 661

Thanks: 1 times
Was thanked: 81 time(s) in 76 post(s)
Oh I didn't realize it was so simple. It looks like your arduino program has no wait so the digital read happens constantly. Try raising the refresh rate of your agent. Or try using an interrupt agent. It has one digital input node that fires on an interrupt instead of on a timer. A regular node fires on a timer at the set refresh rate, so yours is probably doing 32 digital reads per second which is missing your signal.
juhapekka.seppala@saunalahti.fi  
#5 Posted : Friday, July 03, 2015 12:15:40 AM(UTC)
juhapekka.seppala@saunalahti.fi

Rank: Member

Groups: BetaUser, Registered
Joined: 6/4/2015(UTC)
Posts: 24

Hi i tried with different refresh rates and also with compiled program but result is same 3 pulses instead 34.

Interrupt agent, could you tell more about this.

JPS
EmbrioAdmin  
#6 Posted : Friday, July 03, 2015 12:41:38 PM(UTC)
EmbrioAdmin

Rank: Administration

Groups: Administrators
Joined: 12/11/2014(UTC)
Posts: 661

Thanks: 1 times
Was thanked: 81 time(s) in 76 post(s)
The architecture of an Embrio program is that you have nodes organized into agents. Each agent has a refresh rate (in the bottom right of the screen), and all of the nodes in the agent update that many times per second. Your Arduino program does a digital read, and then doesn't wait at all before looping again, so it's doing a huge amount of reads per second, so it's able to catch all of the changes on your pin. On Embrio it's only doing about 32 reads per second (or whatever your refresh rate is), so your pin is changing faster than Embrio is reading. So you need to use an "interrupt" which fires when the pin value changes.

There are two things to try.

First you can use an interrupt agent. I just noticed there's no documentation for this, I'll add it soon. Right click on a folder in the tree and select "new interrupt agent". This agent has a special input node. Pick your pin and set the interrupt type to "change". The trigger will fire whenever the digital pin that you selected changes. You want to have as few nodes as possible on this agent, maybe just a counter. Make the counter's output external (by clicking on the little plug icon next to it), and read that value from a regular agent.

Also you can try writing interrupt code right in a custom Arduino node, like in this example of using a rotary encoder.

Let me know if that does it!
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Notification

Icon
Error