Welcome to Synthiam!

Program robots using technologies created from industry experts. ARC is our free-to-use robot programming software that makes features like vision recognition, navigation and artificial intelligence easy.

Get Started

PWM Control Via JS Code.

Hi Synthiam Community, 

I'm currently putting together a project for some high school students, We are looking to control Roli's track motors via PWM with JS.
I know that there is the PWM control panel, but I need to control via code. I had a search of the forums, didn't find anything(correct me if I'm wrong)
I'm sure I'm just missing something to make it work, any help would be much appreciated.
Does anyone have a code sample or a link to a relevant tutorial? 

Thanks in advance:)

Related Hardware EZ-Robot Roli Rover
Roli's project uses a Dual channel HBridge PWM Movement Panel: https://synthiam.com/Support/Skills/Movement-Panels/Dual-HBridge-w-PWM?id=16067

That Movement Panel also controls both the direction AND pwm (speed). ARC movement panels use a global SPEED() function in JS, EZScript, Python or Blockly. That SPEED() function will control the speed of what ever Movement Panel is added.

A Movement Panel is what is responsible for the robot to move. Here's details of what a Movement Panel is: https://synthiam.com/Support/ARC-Overview/movement-panels

The short answer is use the SPEED() function. In case of JavaScript, you wish to use the https://synthiam.com/Support/javascript-api/Movement/setSpeed
Have a look at the JavaScript manual to see all of the available functions.

More advanced stuff
Now, if you're attempting a lower level (arduino style) programing model where you're wanting to teach the students how PWM and HBridges work... You can use the Digital SET and PWM JS commands. It's far more complicated and you lose the ability for ARC skills to control movements (such as camera control, etc). So i don't know if that's the direction you are heading. But those JavaScript commands would fall under their respective classes/namespaces here

Set Digital: https://synthiam.com/Support/javascript-api/Digital/set
Set PWM: https://synthiam.com/Support/javascript-api/PWM/set