Go Back   EcoModder Forum > EcoModding > Fossil Fuel Free > Open ReVolt: open source DC motor controller
Register Now
 Register Now
 

Reply  Post New Thread
 
Submit Tools LinkBack Thread Tools
Old 04-05-2014, 06:05 AM   #6401 (permalink)
EcoModding Lurker
 
Join Date: Jul 2011
Location: INDONESIA
Posts: 40
Thanks: 20
Thanked 6 Times in 6 Posts
Order the new board of 1K

Paul, I want to buy 2 pcs of 1k board...
I will send money to your paypal...how much will be include shipping cost.
Thank u,
Kukuh
Jakarta


Last edited by KUSAW; 04-05-2014 at 06:07 AM.. Reason: Mistypo
  Reply With Quote
The Following User Says Thank You to KUSAW For This Useful Post:
MPaulHolmes (04-05-2014)
Alt Today
Popular topics

Other popular topics in this forum...

   
Old 04-05-2014, 07:34 AM   #6402 (permalink)
Dreamer
 
Join Date: Nov 2013
Location: Australia
Posts: 350
Thanks: 95
Thanked 214 Times in 151 Posts
Quote:
Originally Posted by MPaulHolmes View Post
I'm getting close to being done with a complete rewrite of the code. I'm pretty sure there's a bug in the original software for the pwm filter. It tries to take sort of a running average for pwm, but look at this:

pwmAverage = (127*pwmAverage + 1*pwmNewValue)/128

Let's say, for instance, pwmAverage is 10, and pwmNewValue is 20. pwmAverage will never be able to creep toward 20. If the new value of pwm average is 10 < pwmAverage < 11, it will be truncated to 10, and won't ever get to 20.
Paul,

If the intention is to have a pwmNewValue of 20 move the pwmAverage towards 20 with each evaluation. Then the pwmAverage needs to be a floating point number or somehow be saved with about 3 decimal places of precision. If an integer is used then a pwmNewValue of 20 isn't high enough to step the average up to the next integer value.

Another approach would be to multiply the pwmAverage by 100 before storing it. Then dividing it by 100 whenever it is used.

pwmAverage = ((( 127 * (pwmAverage / 100)) + (1 * pwmNewValue)) / 128 ) * 100
pwmAverage = ((( 127 * (1000 / 100)) + (1 * 20)) / 128 ) * 100
pwmAverage = ((( 127 * (10)) + (1 * 20) / 128 ) * 100
pwmAverage = (( 1270 + 20) / 128 ) * 100
pwmAverage = (1290 / 128 ) * 100
pwmAverage = 10.078125 * 100
pwmAverage = 1007.8125
Stored as an integer we get 1007

Next evaluation with pwmNewValue = 20 we get
pwmAverage = ((( 127 * (pwmAverage / 100)) + (1 * pwmNewValue)) / 128 ) * 100
pwmAverage = ((( 127 * (1007 / 100)) + (1 * 20)) / 128 ) * 100
pwmAverage = ((( 127 * (10.07)) + (1 * 20) / 128 ) * 100
pwmAverage = (( 1,278.89 + 20) / 128 ) * 100
pwmAverage = (1,298.89 / 128 ) * 100
pwmAverage = 10.147578125 * 100
pwmAverage = 1014.7578125
Stored as an integer we get 1014

And so on and so on until we approach pwmAverage of 20 or pwmAverage stored value of 2000

If you didn't want to change the magnitude of the pwmAverage value (if it is used elsewhere) then you could use a second value to hold the more precise pwmAverage value.
  Reply With Quote
The Following User Says Thank You to Astro For This Useful Post:
MPaulHolmes (04-05-2014)
Old 04-05-2014, 09:08 AM   #6403 (permalink)
PaulH
 
MPaulHolmes's Avatar
 
Join Date: Feb 2008
Location: Maricopa, AZ (sort of. Actually outside of town)
Posts: 3,832

Michael's Electric Beetle - '71 Volkswagen Superbeetle 500000
Thanks: 1,368
Thanked 1,202 Times in 765 Posts
Hi MisterSid! The revision 1.11b code is somewhere in the wiki. Here it is:
Index of /firmware

I used to have a Linux dual boot, since Fran had done that code in Linux, and had a fairly special build environment. That hard drive broke, and I haven't gone back to it. Now, I'm using AVR Studio, but it messes up the use of the bootloader. That's another reason I didn't mind switching to a dsPIC. Well, the dsPIC is also a motor controller micro, and it definitely shows. Everything I wanted it to do, it does very easily.
__________________
kits and boards
  Reply With Quote
Old 04-05-2014, 10:21 AM   #6404 (permalink)
PaulH
 
MPaulHolmes's Avatar
 
Join Date: Feb 2008
Location: Maricopa, AZ (sort of. Actually outside of town)
Posts: 3,832

Michael's Electric Beetle - '71 Volkswagen Superbeetle 500000
Thanks: 1,368
Thanked 1,202 Times in 765 Posts
The 3 ring capacitors have been shipped. They are in MS, whatever that is. haha. Minnesota? Manuscript? Mississippi? Multiple Sclerosis?
Your tracking/waybill number is 361026370772321.
Click on the "Track Shipment" link for tracking information.

https://www.fedex.com/fedextrack/?tr...nguage=english
__________________
kits and boards

Last edited by MPaulHolmes; 04-05-2014 at 02:12 PM..
  Reply With Quote
The Following User Says Thank You to MPaulHolmes For This Useful Post:
flores (04-05-2014)
Old 04-05-2014, 02:14 PM   #6405 (permalink)
PaulH
 
MPaulHolmes's Avatar
 
Join Date: Feb 2008
Location: Maricopa, AZ (sort of. Actually outside of town)
Posts: 3,832

Michael's Electric Beetle - '71 Volkswagen Superbeetle 500000
Thanks: 1,368
Thanked 1,202 Times in 765 Posts
Quote:
Originally Posted by Astro View Post
Paul,
I am a karate expert!
LOL. I'm sorry, my wife and kids left for the store, and I'm working on the software, and thought it would be hilarious to make you say something you didn't say.

I thought of a perfect name for the controller too!!
The "Diarrhea"... Since it gives your car the runs.

There will also be a "diaper" mode, which prevents you from going all over the street. Other "controller making people" have labeled it a "valet" mode.
__________________
kits and boards

Last edited by MPaulHolmes; 04-05-2014 at 04:00 PM.. Reason: controllers don't label things. they are inanimate objects.
  Reply With Quote
Old 04-05-2014, 06:23 PM   #6406 (permalink)
Dreamer
 
Join Date: Nov 2013
Location: Australia
Posts: 350
Thanks: 95
Thanked 214 Times in 151 Posts
Quote:
Originally Posted by MPaulHolmes View Post
LOL. I'm sorry, my wife and kids left for the store, and I'm putting the finishing touches on my superman costume, and thought it would be hilarious to make you say something you didn't say.
It took me a moment to work out what was going on as i read the quoted text first. Actually scrolled back through the thread looking for where i had put a comment like that. Then i went back and finished reading the rest of the post and realised it was a trick. You got me.

I have nothing to do with Karate, my sister however did it for a few years which is the main reason why we are very careful not to make her angry. Sort of like living with the Hulk.

Did the suggestion for pwmAverage help or did i do my normal thing of misunderstanding the question.
  Reply With Quote
Old 04-05-2014, 09:41 PM   #6407 (permalink)
EcoModding Lurker
 
Join Date: Mar 2014
Location: New Zeland
Posts: 4
Thanks: 0
Thanked 2 Times in 2 Posts
Cheers Paul. I will get myself up to speed with the rev2c avr code. Sorry, I just assumed your dsPIC port to might have diverged from the AVR implementation.
The dsPIC33 looks like a big step up for all the reasons you have outlined and it has a decent motor control library as well.
  Reply With Quote
Old 04-05-2014, 10:11 PM   #6408 (permalink)
PaulH
 
MPaulHolmes's Avatar
 
Join Date: Feb 2008
Location: Maricopa, AZ (sort of. Actually outside of town)
Posts: 3,832

Michael's Electric Beetle - '71 Volkswagen Superbeetle 500000
Thanks: 1,368
Thanked 1,202 Times in 765 Posts
Actually, it would be better to see the new dspic code. I'm not doing anything with the avr code. It has diverged quite a bit. Im mostly done, and the main area that seems needing of cleanup is the serial. Could I email it once done? Its already so different.


Astro, yes that was a very helpful suggestion! I had resorted to a standard average, but I think your suggestion is better.
__________________
kits and boards
  Reply With Quote
Old 04-06-2014, 12:51 PM   #6409 (permalink)
PaulH
 
MPaulHolmes's Avatar
 
Join Date: Feb 2008
Location: Maricopa, AZ (sort of. Actually outside of town)
Posts: 3,832

Michael's Electric Beetle - '71 Volkswagen Superbeetle 500000
Thanks: 1,368
Thanked 1,202 Times in 765 Posts
Here's the modified throttleAverage code, as a sample. Thanks for the suggestion, Astro! I'm making the same change to pwmAverage and temperatureAverage. Totally unreadable, but pretty fast. haha:
Code:
throttleAverageTimes1024   //    = (31*throttleAverageTimes1024)/1024 + 1*ADThrottle) / 32 * 1024;
                           //    = 32*(throttleAverageTimes1024/1024) - 1*(throttleAverageTimes1024/1024) + 1*ADThrottle) / 32 * 1024; 

= ((throttleAverageTimes1024 >> 5) - (throttleAverageTimes1024 >> 10) + (long)ADThrottle) << 5;
__________________
kits and boards
  Reply With Quote
The Following User Says Thank You to MPaulHolmes For This Useful Post:
Astro (04-06-2014)
Old 04-06-2014, 07:32 PM   #6410 (permalink)
Dreamer
 
Join Date: Nov 2013
Location: Australia
Posts: 350
Thanks: 95
Thanked 214 Times in 151 Posts
Quote:
Originally Posted by MPaulHolmes View Post
Here's the modified throttleAverage code, as a sample. Thanks for the suggestion, Astro! I'm making the same change to pwmAverage and temperatureAverage. Totally unreadable, but pretty fast. haha:
Code:
throttleAverageTimes1024   //    = (31*throttleAverageTimes1024)/1024 + 1*ADThrottle) / 32 * 1024;
                           //    = 32*(throttleAverageTimes1024/1024) - 1*(throttleAverageTimes1024/1024) + 1*ADThrottle) / 32 * 1024; 

= ((throttleAverageTimes1024 >> 5) - (throttleAverageTimes1024 >> 10) + (long)ADThrottle) << 5;
I had to look up a wiki to find out what >> did in C programming language.
(One day i will have to learn C.)
A bitwise shift. Very neat.
Sometimes readability needs to take a back seat to performance. After all that's what comments are for.

  Reply With Quote
The Following User Says Thank You to Astro For This Useful Post:
MPaulHolmes (04-06-2014)
Reply  Post New Thread




Similar Threads
Thread Thread Starter Forum Replies Last Post
Paul and Sabrina's Cheap 3 Phase Inverter (AC Controller) with Field Oriented Control MPaulHolmes Fossil Fuel Free 3480 05-04-2022 05:43 PM
Paul & Sabrina's Cheap EV Conversion MPaulHolmes Fossil Fuel Free 542 11-12-2016 09:09 PM
Three Dirt Cheap DIY Electric Cars - Part 5 SVOboy EcoModder Blog Discussion 0 12-12-2008 04:10 PM



Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Content Relevant URLs by vBSEO 3.5.2
All content copyright EcoModder.com