usbdevicemicrocontrollermotordriver

Control stepper motors via USB


I'm doing a USB device is to control stepper motors. I've done this before using a parallel port. because these ports do not exist in current motherboards, I decided to implement a USB communication between my device and the PC (host). To achieve My objective, I endowed the freescale microcontroller the device with that has a USB module 12Mbps. My USB device must receive 4 bytes (one for each motor driver) at a given time, because every byte is a step that should move the engine. In the PC (Host) an application of user processes a text file with information and make the trajectory coordinates sending bytes at a certain rate for each motor (time is trivial to achieve the acceleration and speed of the motors) .

Using the parallel port was an easy the task because each byte is sent sequentially to a time determined by the user app.

doing a little research about full speed USB protocol understood that the frame is sent every 1ms. then you can send 4 byte or many more every 1ms but I can not manage time like I did with the parallel port. My microcontroller can send up to 64 bytes per frame (Based on transfer papers type Control, Bulk, Int, Iso ..).

question 1:

I want to know in what way I can send 4-byte packets faster than every 1 ms?

question 2:

What type of transfer can advise me for these type of devices?

Thanks.


Solution

  • Like Ricardo said, USB-serial will suffice.

    As for the type of transfer, try implementing a CDC stack and use your SCI receiver to listen for PC commands. That will give you a receive buffer which will meet your needs.

    When you have all 4 bytes, fire off the steppers! Four bytes should take µs.

    Check with Freescale to see if your processor is supported.

    http://cache.freescale.com/files/microcontrollers/doc/support_info/USB_STACK_RELEASE_NOTES_V4.1.1.pdf?fpsp=1

    There might even be some sample code to get you started.

    -Cheers