Monday, September 7, 2009

Arduino PWM Part 2

Labor Day weekend nearly over, a couple of more hours and I was able to finish what I had set out to do, with time to spare, so will go wash my car . Anyway you saw in my previous post, how I used PWM to control the speed using L293 H Bridge and I said that I will try to build an interface, in C# that will control the speed, direction and turn the motor on and off.
The program was easy, as it was just opening the serial port and sending the data, using a fixed protocol. If you go through the code you will be able to figure that out. I don’t want to explain it, because it’s not convoluted. But it did not work as expected. I had to put a delay between reading data and I am not sure why I had to do that. I did search the internet, to find out why a delay is required, but couldn’t find anything. Just found one posting, which didn’t cover the details, on why we needed. I guess its because it takes some time for the serial data to load. I am not sure how important this is for me. But for RTOS, I guess its important and I hope this delay will be a stumbling block in the future and then I will find a way to tackle it. But for now I will just put a delay of 3ms.
In the video you can see the various scenario, that is controlled by the C# code. I have attached the code and the project in the zip file, if anyone ones to download it. Make sure you connect to the correct ports. If in future I fabricate this board, then I will include the PCB dig., which should be simple. But if anyway wants to know it, do let me know.


Files-->
http://www.esnips.com/doc/7a7cc87e-add6-4ae2-91e2-c8263b51effb/motor-with-interface
http://www.esnips.com/doc/1df0e0b1-ad42-4a7c-9095-246b3c9e04b3/Arduino.net

Saturday, September 5, 2009

Arduino PWM Part 1

Arduino PWM part 1 without Computer interface. Using L293 H bridge and connected it to PWM port 11. If you see the video, the motor runs in 3 different speed. First using digital write, which uses full duty cycle. Then 50/255 duty cycle and then 100/255. Next step is connecting it using .NET to a windows application.