General Discussion

Coordinator
Jun 10, 2010 at 1:38 PM

Post questions or comments here.

Mar 19, 2011 at 2:34 PM
 
Problems: when setting digitalpin, it sets inverted value

Hi to all,

I'm using Rhyduino with Arduino One, but it happend this:

Sequence actions:
1 - call DigitalPins[_pin].SetPinValue(DigitalPinValue.High); > Not happend nothing
2 - call DigitalPins[_pin].SetPinValue(DigitalPinValue.Low); > It's turn on a led to pin setted
3 - call DigitalPins[_pin].SetPinValue(DigitalPinValue.High); > It's turn off a led to pin setted

Why?

I downloaded Firmata-2.2 and I uploaded StandardFirmata on using Arduino0022 console.

Can you help me?
Sep 22, 2011 at 5:50 AM
Edited Sep 22, 2011 at 5:50 AM

I'm afraid I'm experiencing the same symptoms as dconcilio as well. I implemented some bare-minimum digital-write code and noticed pin 13 wasn't blinking the number of times that I specified. At first I thought the thread was exiting before Rhyduino could finish up its business, but I've had no luck with every attempt (multiple threads, spin-waits, sleeps). Most of my commands go thru, but the first and last couple don't seem to have much rhyme or reason. It almost looks like Rhyduino waits to send the command to the arduino until it is given the next, different, command on the same pin.

eg: the arduino's behavior is always 1 command behind what's expected from the following code:

static void Main(string[] args)
{
 using (Arduino a = new Arduino("COM3"))
 {
  DigitalPin p = a.DigitalPins[13];
  p.SetPinMode(PinMode.Output);

  int count = 4;
  for (int i = 0; i < count; i++)
  {
   p.SetPinValue(DigitalPinValue.High);
   Console.WriteLine("Set high");
   Thread.Sleep(TimeSpan.FromSeconds(1));


   p.SetPinValue(DigitalPinValue.Low);
   Console.WriteLine("Set low");
   Thread.Sleep(TimeSpan.FromSeconds(1));
  }
 }
}

Sep 24, 2011 at 7:59 AM
Edited Sep 24, 2011 at 8:06 AM

After digging thru the code w/ some breakpoints, it looked as though the bitmask being generated was completely zero when it should have had at least a 1 in it on the first SetPinValue(high).
I saw that the code to generate the bitmask hits a function called GetPinValue() and asks if the current pin is set high, then includes its respective pin index in the bitmask.
However, the GetPinValue method asks the current pin class what it's value is, which hasn't been set yet by SetPinValue.
My fix (which still needs to be looked at more) is in SetPinValue of DigitalPin.cs,

move:
_value = digitalPinValue;
somewhere before:
_arduino.Post(FirmataEncoder.BuildDigitalWriteRequest(PinToPort(PinNumber), _arduino.GetPortValue(PinNumber)));

Otherwise the value is always a command behind.

The library is great so far, I feel like this was just a simple optimization/refactoring bug that was overlooked at some point.
Please let me know if you have any input on this topic.

Oct 26, 2011 at 5:56 PM

Could you elaborate on your xbee setup?  Was it just Point to Point or Point to Multipoint?

Oct 26, 2011 at 11:13 PM
Edited Oct 26, 2011 at 11:13 PM

To whom was this previous question directed?
I don't have an xbee shield. I was just connected directly to my arduino running the standard Firmata library via usb based serial port.

Oct 27, 2011 at 12:39 PM

 

RhyMednick.  I used the "reply" link on his original post, apparently that doesn't do anything differently than the reply button at the bottom of the screen.

Nov 27, 2012 at 8:04 PM
Edited Nov 27, 2012 at 8:05 PM

plz people help me out, 

 

looked at that DigitalPinMonitorSample , but "DigitalPinValueChanged" does not work..(for winforms)  test's pins out to till, "Press <enter> to end." and that's it. :S

in console , everything is working.

 

what i mean is that , i want to make winform report me if some pin get's "HIGH" value after it's been "LOW".

Coordinator
Nov 30, 2012 at 1:22 AM
Hi hani93 -

The problem you're describing is one that I've experienced as well, and I was never successful in identifying the cause. I've gone so far as to rewrite the bulk of the code to test out different strategies for decoupling the serial communication from the interface but all had the same result - as soon as WinForms came into the equation, things became really unpredictable. Ironically, the more solidly I isolated the components of the library, the more reliably it failed to report changes in a way that could be displayed on a form. After spending well over 10x my initial time investment in the project, I gave up. I've left the code there because there are still some useful portions of it, but as far as I'm concerned, the project is dead. I'd be thrilled if someone were able to figure out what the problem is, but not optimistic that anyone talented enough would be willing to invest the time.




On Tue, Nov 27, 2012 at 1:04 PM, hani93 <notifications@codeplex.com> wrote:

From: hani93

plz people help me out,

looked at that DigitalPinMonitorSample , but "DigitalPinValueChanged" does not work..(for winforms) test's pins out to till, "Press <enter> to end." and that's it. :S

in console , everything is working.

Read the full discussion online.

To add a post to this discussion, reply to this email (rhyduino@discussions.codeplex.com)

To start a new discussion for this project, email rhyduino@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Nov 30, 2012 at 3:24 PM

i've managed to get it eventually to work...

Using arduino = New Rhyduino.Arduino(SelectedPort)

arduino.Connect()


AddHandler arduino.DigitalPinValueChanged, AddressOf Me.ArduinoDigitalPinValueChangedHandler�

 

'and then comes other commands...

(see full code here: link )

'what i missed was arduino.connect command

 

but anyway, thanks for reply ;-)