C# example
Forums:
Can someone please help me on the way in using the UltraBorg with Windows 10 IoT on my Raspberry Pi 2B, please?
I'm looking for an example on addressing the UltraBorg via C#.
I can already address the card through the I2C, but I'm having trouble with the rest of the communication.
How can I read the HC-SR04 distance or command the connected servo?
I think I'm missing a link for the different commands?
The board works with the python examples so the connections are ok, but I would like to use C#...
Thanks to anyone who can help me on the way :-)
piborg
Mon, 02/08/2016 - 11:48
Permalink
Windows IoT C#
All you should really need to do is mimic the same I2C messages that the
UltraBorg.py
script is sending / receiving already.I can give you a couple of examples, but they are completely untested.
All of the C# code has been derived from: https://ms-iot.github.io/content/en-US/win10/samples/I2CAccelerometer.htm
Setting up the connection:
Setting the position for the first servo:
Reading the filtered distance from sensor #1:
Wim Desimpel
Mon, 02/08/2016 - 22:53
Permalink
GetDistance1
Thank you for the quick reply.
I can move the servo with the SetServoPosition function,
but the ubI2C.WriteRead in GetDistance1 keeps returning FFFF?
I loop the function 50 times, but always the WriteRead returns 4x255?
The python code confirms that the USM is working and on USM port 1.
What could I be missing?
piborg
Tue, 02/09/2016 - 10:14
Permalink
UltraBorg not reading from C#
It may simply be that a slight gap is required between the write and read operations.
Usually this is handled by the remote device (UltraBorg in this case) using a method called clock streching.
Unfortunately when testing we found the Raspberry Pi did not seem to work correctly when we used clock stretching.
Try this version which splits the write and read into two operations to see if it works that way:
Wim Desimpel
Tue, 02/09/2016 - 22:06
Permalink
Solved
Works like a charm :-D
Thank you!!!
john.kattenhorn...
Fri, 03/04/2016 - 08:15
Permalink
This is awesome! I can't wait
This is awesome! I can't wait to explore what I can do with PiBorg hardware and Windows IoT
john.kattenhorn...
Sat, 10/28/2017 - 20:17
Permalink
Added github link to C# port of PicoBorg Rev controller code
Hi,
There's already a few people that have already said they've ported the python code to C# but I could not find any complete examples so I've started one here:
https://github.com/johnkattenhorn/picoborgrev