Arduino and motor Shield help

Topics and questions about AMC, h-bridges, JRK's etc.

Re: Arduino and motor Shield help

Postby rainman2002z » Sat 29. Sep 2012, 18:19

Well arduino in place with adafruit motor shield for servo testing and two servo`s connected .. i will admit a noob but understand coding .. tried examples and can only get one servo running, tried seperate power supply to servo .. tested all working with servo sketch and fine. only mod to example is to change to pin 9, 10 on servo attach, servo thats runs is on pin 10

i think i am missing something really really simple . my first step was to get model working and go from there .. have now purchassed couple of dc motors also ..

any ideas
rainman2002z
 
Posts: 8
Joined: Mon 3. Sep 2012, 21:10
Has thanked: 0 time
Been thanked: 0 time

Re: Arduino and motor Shield help

Postby sirnoname » Mon 8. Oct 2012, 20:46

My setup is now complete.
The first try with the arduino SDK and a switching port pin has shown me 117kHz as a update frequency of the main loop in the oscilloskope.
To say it directly: if I only switch a simple pin and the Atmel has a main frequency of 16MHz this 117kHz was a big fail.
After some request some people have lead me to either do the work without the arduino SDK or go to direct port manipulation.
Tomorow I will try the direct manipulation before I do workarounds.

If a answer is correct or did help you for a solution, please use the solve button.
User avatar
sirnoname
Site Admin
 
Posts: 1829
Images: 45
Joined: Thu 1. Sep 2011, 22:02
Location: Munich, Germany
Has thanked: 35 times
Been thanked: 128 times

Re: Arduino and motor Shield help

Postby tronicgr » Mon 8. Oct 2012, 21:12

Keep in mind that these h-bridges (and most of them actually) can operate up to 20-25Khz... And you should try making custom PWM library to use the hardware PWM instead of the 8-bit "software" PWM provided by the existing libraries!

Also the loop should contain other code too (even more hidden in libraries) that take time to execute. My loops are around 1Khz in AMC boards but I handle data and calculations and sensors for two motors... ;)

Best Regards
Thanos
User avatar
tronicgr
 
Posts: 624
Images: 11
Joined: Tue 20. Mar 2012, 22:10
Location: San Diego, CA
Has thanked: 130 times
Been thanked: 50 times

Re: Arduino and motor Shield help

Postby sirnoname » Mon 8. Oct 2012, 21:37

A update frequency below 1kHz is a nogo for this project and I go back and use the former chip I have used for this projekt. However it is a challange to do this with a arduino ;)
If a answer is correct or did help you for a solution, please use the solve button.
User avatar
sirnoname
Site Admin
 
Posts: 1829
Images: 45
Joined: Thu 1. Sep 2011, 22:02
Location: Munich, Germany
Has thanked: 35 times
Been thanked: 128 times

Re: Arduino and motor Shield help

Postby sirnoname » Wed 10. Oct 2012, 13:38

Good news so far, the direct port access will increase the pulse to 1,1MHz. So it is possible to speed up the arduino with the SDK and the usage of machine code. You cannot use the commands of the arduino SDK but you can use the native C language in the same way.
The code on the first page of this thread can be speed up if you change this parts.
The loop code does some delay, so the port IO speed can get up to 4MHz with inline code.
The warnings are clear: if you use direct port access and you switch the RS232 pin to an output the arduino is not usable anymore because the serial uploader is out of business ;)
You need a external programer to clear the chip and you need the arduino uno bootloader as file to program it into the chip again. I do not have the bootloader for now but I think it is somewhere on the arduino page ...

An example for 4MHz on Pin13 speedup with own loop code:
Code: Select all
void loop()
{
  while(1==1)
  {
   PORTB =32;
   PORTB = 0;
  }
}


1,1MHz with direct port manipulation:
Code: Select all
void loop()
{
   PORTB =32;
   PORTB = 0;
}


117kHz with the original arduino style:
Code: Select all
void loop()
{
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
}


The goal is to stay with the arduino SDK because it can be easy used by anyone and it is well described.
If a answer is correct or did help you for a solution, please use the solve button.
User avatar
sirnoname
Site Admin
 
Posts: 1829
Images: 45
Joined: Thu 1. Sep 2011, 22:02
Location: Munich, Germany
Has thanked: 35 times
Been thanked: 128 times

Re: Arduino and motor Shield help

Postby sirnoname » Thu 11. Oct 2012, 19:45

Can someone tell me the used pin of the shields, I will use the same one to be compatible ;)
If a answer is correct or did help you for a solution, please use the solve button.
User avatar
sirnoname
Site Admin
 
Posts: 1829
Images: 45
Joined: Thu 1. Sep 2011, 22:02
Location: Munich, Germany
Has thanked: 35 times
Been thanked: 128 times

Re: Arduino and motor Shield help

Postby prilad » Thu 18. Oct 2012, 09:48

tronicgr wrote:Now if you have a 10ms delay in reaction time from the controller it will add up to the delay of the reaction of the motor exponentially. Here are some calculations:

10ms * 10ms = 100ms total delay
10ms * 100ms = 1sec total delay
10ms * 200ms = 2sec delay!!!


I'm sorry, Thanos. But I can not agree with you ;) . Why did you decide that the reaction of the motor exponentially??? From your calculations obtained some fantastic delay. I want to once again draw your attention to the your video.

http://www.youtube.com/watch?feature=pl ... NfZLTcgIQ#!

At the seconds 50th you are just sets the period on 100 ms. However, the huge delay = 1 sec not happening. There is only a distortion of the signal, its deviation from the desired sinusoidal form.

Below I have listed a series of illustrations to explain the reason for these distortions that arise when the period of data is greater than the time of processing the PID

period = 1ms

period = 25 ms

period = 62 ms

All comparison


This "theoretical" cases are very close to "real" ones (1 ms, 33 ms, and 100 ms) what you use at the video. There are not delays more then SUMM of "motor reaction" delay and "send period" delay.

Regards,
Ale.
User avatar
prilad
 
Posts: 174
Images: 1
Joined: Tue 3. Apr 2012, 14:20
Location: Dubna, Moscow reg., Russia
Has thanked: 3 times
Been thanked: 37 times

Re: Arduino and motor Shield help

Postby ferslash » Tue 6. Nov 2012, 19:08

Dear motion Dave and sirnoname, i got loost with this thread... is it ended? was it posible to use arduino for a sim?

best regards

fer
ferslash
 
Posts: 226
Images: 4
Joined: Tue 3. Jul 2012, 18:08
Location: Mexico, Guadalajara
Has thanked: 8 times
Been thanked: 1 time

Previous

Return to Controllers and Drivers

Who is online

Users browsing this forum: No registered users and 2 guests