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
Australia
Asked
Resolved Resolved by DJ Sures!

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
PRO
Synthiam
#1  
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
#2  
Thanks DJ, 

I completely forgot to write a reply, Got it all working. Turned out I just forgot some basic fundamentals of H-bridges.

Cheers.
PRO
Synthiam
#3   — Edited
Great, mark. 

however consider the advantage of a Movement Panel is you don’t need to code the logic. Instead, you can use movement commands with the speed parameter. That will tell the Movement Panel to do its thing, even for an hbridge. 

the advantage to this is agnostic robot hardware. Consider building a robot with an hbridge that performs a specific task using an hbridge movement panel. But, now you can replace that hbridge Movement Panel with a drone or Auto Position for Hexapod or humanoid. 

you see, any project can use any movement panel. The idea is to not code something specific for a specific hardware configuration - to allow agnostic hardware configurations. 

Make sense? Glad you got something working but consider my feedback - as it extends capability and expandability of a robot

ps, read more about movement panels here: https://synthiam.com/Support/ARC-Overview/movement-panels