Welcome to Synthiam!

The easiest way to program the most powerful robots. Use technologies by leading industry experts. ARC is a free-to-use robot programming software that makes servo automation, computer vision, autonomous navigation, and artificial intelligence easy.

Get Started
United Kingdom
Asked — Edited
Resolved Resolved by DJ Sures!

Getpwm Returning "0"

I want to return the value from D1 and D0 whilst tracking an object, i'm using the GetPWM command but only ever get a "0" returned. Am i missing something?

Code:


ControlCommand("Camera", CameraColorTrackingEnable)

:TrackingLoop

$head0=GetPWM( D0 )
$head1=GetPWM( D1 )
print($head0)
print($head1)

sleep(1000)

Goto(TrackingLoop)


ARC Pro

Upgrade to ARC Pro

Get access to the latest features and updates before they're released. You'll have everything that's needed to unleash your robot's potential!

AI Support Bot
Related Content
Synthiam
PRO
USA
#1  
you are using the wrong function, replace GetPWM with GetDigital.

Quote:


GetPWM (digitalPort)
Gets the PWM (Pulse Width Modulation) of specified port
PWM is between 0 and 100


Quote:


GetDigital( Port )
Returns the Digital value of the specified port as a 0 or 1


GetPWM returns the last value used with a PWM function.

ex:

Code:


PWM(D0, 75)
PWM(D1, 100)
Print(GetPWM(D0)) => 75
Print(GetPWM(D1)) => 100
PRO
Synthiam
#2  
I believe you are attempting to determine the position of a servo? If that is the case, use GetServo(). As stated by @ptp, the GetPWM is reserved for PWM specific functions, which is identified by its naming convention PWM vs SERVO.

Find out how a servo works from the learn section here: http://www.ez-robot.com/Tutorials/Lesson/48?courseId=6

Additionally, there are dozens of variables for the camera control - which you can view by looking at the Variable Tab while editing. More information on editing EZ-Script can be found in the learn section here: http://www.ez-robot.com/Tutorials/Course/6

Camera variables can help to determine the physical location of the object on the screen.

However, if you are looking to read a servo position, use GetServo(). The JD project which you are building from has some script examples that demonstrate, such as PointAndTrack
United Kingdom
#3  
Thanks DJ.

getservo() works a treat