Read three pulse values in a script

10 years 11 months ago #29527832 by marcusbarnet
I\'m trying to use a Futaba receiver on my HDC2450 controller but I\'m having problems while I try to read pulses values using a script.

In particular, I\'m using RC1, RC2 on pins 15 and 16 and RC3 on pin 4.

I\'m able to successfully read RC1 and RC2 values by using
Throttle = getvalue(_CIP, 1)
Steering = getvalue(_CIP, 2)

but I\'m not able to read RC3 since I always read zero values if I use this code
Third-channel = getvalue(_CIP, 3)
print(\"third channel \",Third-channel,\" T= \",Throttle,\" S= \",Steering, \"\\\\n\")

However, in \"Pulse In\" section in Roborun utility I can see that pulses values in Pln1, Pln2 and Pln3 changes everytime I send commands from my transmitter but I\'m not able to read any values from getvalue(_CIP, 3) in my script.
I can read values only from two pulses channels (_CIP, 1) and (_CIP, 2) at a time, is it normal?

Can you help me, please?
Do I need to use any particular configuration?

Please Log in or Create an account to join the conversation.

10 years 11 months ago #29527833 by marcusbarnet
Any suggestions? :)

Please Log in or Create an account to join the conversation.

10 years 11 months ago #29527835 by Griffin Baker
Replied by Griffin Baker on topic Re:Read three pulse values in a script
This isn\'t normal for sure. Other than maybe a syntax error, I couldn\'t really say. Might need some time to look this up.

Could you provide the script command that you have for printing the CIP 1 and CIP 2 values?

Please Log in or Create an account to join the conversation.

10 years 11 months ago #29527837 by marcusbarnet
The testing code I\'m using is very simply:
Option Explicit
Dim Throttle as Integer
Dim Steering as Integer
Dim third-channel as Integer

top:
\' Read Commands that arrived on the RC pulse inputs
Throttle = getvalue(_CIP, 1)
Steering = getvalue(_CIP, 2)
third-channel = getvalue(_CIP, 3)

\' Print on the console for debugging
print(\"sonar \", third-channel,\" T= \",Throttle,\" S= \",Steering, \"\\n\")

wait(20)
goto top

Wire connections are OK for sure, but I\'m not able to read the pulse on RC3 with this script even if I see all the pulses changing in Roborun utility as Pln1, Pln2, Pln3.
I successfully read RC1 and RC2 with this script, but I always receive zero from RC3 even if pulse value for RC3 is not zero as showed in Roborun utility.

Please Log in or Create an account to join the conversation.

10 years 11 months ago #29527838 by Griffin Baker
Replied by Griffin Baker on topic Re:Read three pulse values in a script
What you can try doing is using the _pic command. _PIC can be used any of the pulse input available.

Also, you can use these commands in the console tab of roborun+.

Try that.

Please Log in or Create an account to join the conversation.

10 years 11 months ago #29527839 by marcusbarnet
I didn\'t understand very well your suggestion.

Can you please explain it better?

At the moment, I run the script and then I read the print statements in the roborun console.

How do I have to use the _PIC commands? and for what?

Please Log in or Create an account to join the conversation.

10 years 11 months ago #29527840 by Griffin Baker
Replied by Griffin Baker on topic Re:Read three pulse values in a script
The _PIC command reads the pulse inputs converted. Page 159 of users manual. Since you are able to read the other 2 but not the 3rd, I suggested using a different query command. The _CIP reads back the internal pulse command. It appears that the the command can only address the first 2.

_PIC nn

In your case it would read something like this.
third-channel = getvalue(_PIC, 3)

Please Log in or Create an account to join the conversation.

10 years 11 months ago #29527841 by Griffin Baker
Replied by Griffin Baker on topic Re:Read three pulse values in a script
With regards to doing a query from the console tab of Roborun+, you would use

?PIC 3

This would query pulse input 3 that has been converted.

Please Log in or Create an account to join the conversation.

10 years 11 months ago #29527844 by marcusbarnet
I tried wih PIC command but it always read zero values..

Please Log in or Create an account to join the conversation.

10 years 11 months ago #29527845 by Griffin Baker
Replied by Griffin Baker on topic Re:Read three pulse values in a script
Have you tried the (_PI 3)?

This will gather the pulse input that is not converted like the (_PIC 3).

Are you doing this command through script, console, or both?

?PI 3

Do you get anything from console of you do the ?PIC 1 and ?PIC 2.?

Please Log in or Create an account to join the conversation.

Moderators: tonysantoni
Time to create page: 0.080 seconds