[Swansea Hackspace] code structure

Justin Mitchell justin at discordia.org.uk
Tue Feb 5 17:36:41 GMT 2019


On Tue, 2019-02-05 at 14:56 +0000, Andy Davies wrote:
> Hi
>  
> Just wanted to check with you guys so see what would be the best way
> to structure some code.
>  
> I have four stepper motors controlled by a windows form via an
> Arduino.
> 
...
> Any suggestions as to how to structure the code will be most welcome.


Personally, I would have the PC->Arduino instructions to be able to set
target positions for the steppers, then have a synchronize/activate
command, so that you don't have a time delay between one being updated
and the next.

in code structure, probably a bunch of globals with the target position
numbers, have the main loop read the info from the pc and update the
targets as commands come in, and a timer interrupt routine which moves
the motors towards their target positions a little bit each time
around.

that would be my initial approach anyway







More information about the Hackspace mailing list