1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[Resolved]32 Channel USB GPIO / C# sample app not working function

Discussion in 'GPIO Modules' started by Christophe Raoult, Jun 1, 2015.

  1. Christophe Raoult

    Christophe Raoult New Member

    Joined:
    Jun 1, 2015
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Gender:
    Male
    Location:
    France
    Dear

    I would like to use the 32 Channel USB module as follow:
    Pin 0 - 15 as output for Led
    Pin 16 - 31 as input for position detector.

    I have dowload your C# app and manage to drive the board.
    I have two errors/missing functions.

    I'm not able to get the status of Pin 16- 31 by read button ( i have update the code as the substring was not on correct place) but respond from RSR232 same even if i move my switch. Result are good with the ReadAll function.

    I m not able to switch ON/OFF my led on port 0 to 15 with WriteAll function. I manage to do one by one with the Set/Clear method.

    To do , i enter the port COM
    set iomask to FFFFFFFF
    set iodir to FFFFOOOO

    I have a Led On IO8 that work with set/clear but not if i put write All FFFFFFFF or WriteALL OOOOOOOO
    I have readALL to FFFEFFFF if switch is Off on IO8 and FFFFFFFFF if switch is On on IO8 but
    i m unable to get by read GPIO number to 16
    Please advice.

    Regards
     
  2. admin

    admin Administrator Staff Member

    Joined:
    Jan 23, 2015
    Messages:
    169
    Likes Received:
    11
    Trophy Points:
    18
    Hello Christophe,

    I apologize but I couldn't figure out if you were able to execute the commands on a serial terminal emulation software and get them working. Can you please confirm ?

    Thanks,
    Tom
     
  3. Christophe Raoult

    Christophe Raoult New Member

    Joined:
    Jun 1, 2015
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Gender:
    Male
    Location:
    France
    Dear Tom

    I have try with putty ang get same result.
    Could ou first confirm than the mask is MSB or LSB first. I'm considering is MSB.
    So to have IO0-IO15 as ouput and IO16-IO31 as input i do in putty

    ver
    00000008
    >gpio iomask ffff0000
    >gpio iodir ffff0000
    >gpio set 8
    >gpio clear 8
    >gpio readall
    FFFE0002
    >gpio read 16
    1
    >gpio readall

    >gpio readall
    FFFF0002
    >gpio read 16

    >gpio read 16
    1
    >gpio writeall ffffffff
    >gpio writeall 00000000
    >ff000002

    So as you see some comand return nothing.
    the clear and set on pin 8 work and light a LED.
    The writeall fffffff and writeall 00000000 have no effect.
    On pin 16 i have a switch.
    We see the value changed with readall (FFFE0002 and FFFF0002) but nothing change with "gpio read 16", i get always same value 1.

    Please advise!

    Regards
     
  4. admin

    admin Administrator Staff Member

    Joined:
    Jan 23, 2015
    Messages:
    169
    Likes Received:
    11
    Trophy Points:
    18
    Hello Christophe,

    Thanks for the details. We will try the same steps here in our lab and will get back with more info as soon as possible.

    Thanks,
    Tom
     
  5. Christophe Raoult

    Christophe Raoult New Member

    Joined:
    Jun 1, 2015
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Gender:
    Male
    Location:
    France
    Dear Tom

    I have successfully manage to use the writeall and readall function.
    I still have a strange behavior with the read a particular value from IO16.
    I have a spare question.
    I plan to use readall function to get value of my 8 switches in one command.
    I have added a timer to query value to your C# app.
    I would like something dynamic so i query for now each 500ms.
    Do you have any limitation or recommendation of the timer of this loop?

    regards
     
  6. admin

    admin Administrator Staff Member

    Joined:
    Jan 23, 2015
    Messages:
    169
    Likes Received:
    11
    Trophy Points:
    18
    Hello Christophe,

    Looks like the read command that you are using is incorrect. "gpio read 16" is incorrect and to read IO16, teh correct command is "gpio read G". Can you please try the correct command and let me know if it works ?

    Thanks,
    Tom
     
  7. Christophe Raoult

    Christophe Raoult New Member

    Joined:
    Jun 1, 2015
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Gender:
    Male
    Location:
    France
    Hi Tom

    You perfectly right. I see this after in you user guide.
    In any case you sample app in C# put me in error as in read function we found
    Code:
     if (int.Parse(gpioNumberReadBox.Text) < 32)                                               //condition
      {
              try
              {
                     serialPort1.DiscardInBuffer();                                                    //discard input buffer
                     serialPort1.Write("gpio read " + gpioNumberReadBox.Text + "\r");  
     
    Meaning the function wait for an integer in the test and write an integer on serial write command.
    By modify it to accept letter i have good result.

    Thanks.
    Regards
     
  8. admin

    admin Administrator Staff Member

    Joined:
    Jan 23, 2015
    Messages:
    169
    Likes Received:
    11
    Trophy Points:
    18
    Hi Christophe,

    Happy to hear that the issue is resolved. I'll mark this thread resolved.

    We will take a look at the sample code and fix it during the next revision.

    Thanks,
    Tom
     

Share This Page