Page 1 of 1

DC Motors

Posted: Sun May 08, 2022 9:39 pm
by fwall
Hi there,

I am trying to use the DC motor component in my code and I need it to move for 10 seconds. I have tried using the component macros forwards(10) and coast but is seeming to stop early, of if I use forwards(1) it won't stop! Would greatly appreciate if someone could explain how they function and how I can best code them to rotate forwards for 10 seconds and also backwards for 10 seconds. I can't find much online.

Thanks in advance

Re: DC Motors

Posted: Sun May 08, 2022 10:12 pm
by BenR
Hello,

The number assigned is the speed when using PWM or HBRIDGE control method. For simple on/off the number will make no difference.

Sounds like your program needs to do the following.

Forwards (1)
Delay S (10)
Stop ()

You might need a further delay at the end, if you're inside a loop with no delay at the end then we will go straight back into Forward which will appear like the Stop function never got called.

Hope this helps.

Re: DC Motors

Posted: Sun May 08, 2022 10:27 pm
by medelec35
Hi.
If you are interested, I posted an example on this post.

Re: DC Motors

Posted: Sun May 08, 2022 10:34 pm
by chipfryer27
Hi

Have you looked at the component example yet?

https://www.flowcode.co.uk/wiki/index.p ... C_Motor_()

How are you connecting your motor? The example is for a Full-Bridge config. If you can share your flowchart and how you are connecting (even if just simulation) I'm sure the forum can assist.

Regards

Edit...
Seems Ben and Medelec beat me to posting <s> Generally speaking, always do as they suggest :)

Re: DC Motors

Posted: Thu Nov 24, 2022 2:35 pm
by PD1404
Hi,
When I use a program as mentioned by others. I am getting a message as 'one or more pins of component motor-full bridge 2 are not connected to the microcontroller.
Can anyone tell me what I have to do to rectify this issue.

Re: DC Motors

Posted: Thu Nov 24, 2022 2:56 pm
by Steve-Matrix
Right-click the motor component and select "properties". Then in the Properties window make sure any pin connections are correct. Each one will either start with a "$" or be labelled as "Unconnected". Ensure that all of these are correctly assigned to a valid pin for your microcontroller by clicking on the port/pin value (or the "unconnected" text) in the right column of the property list.