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-06-2014, 08:45 PM   #6411 (permalink)
EcoModding Lurker
 
Join Date: Mar 2014
Location: New Zeland
Posts: 4
Thanks: 0
Thanked 2 Times in 2 Posts
Quote:
Originally Posted by Astro View Post
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.
Bitwise shift is a much faster alternative to multiply/divide by factors of 2 and a good complier will usually look for places where it can switch out actions like multiply by 32, divide by 1024 etc. and replace them for you. When looking for speed improvements it is often wise to decomplie the .hex file to check though.

Paul: Feel free to email the dsPIC code at any stage.

  Reply With Quote
The Following User Says Thank You to MisterSid For This Useful Post:
MPaulHolmes (04-06-2014)
Alt Today
Popular topics

Other popular topics in this forum...

   
Old 04-07-2014, 01:30 AM   #6412 (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,362
Thanked 1,202 Times in 765 Posts
I'm confused. must check my work. hahaha. Ya, sticking with scaling by 1024 is a good idea, since it matches the A/D resolution.
__________________
kits and boards

Last edited by MPaulHolmes; 04-07-2014 at 02:22 AM..
  Reply With Quote
Old 04-07-2014, 07:43 AM   #6413 (permalink)
EcoModding Lurker
 
Join Date: Mar 2014
Location: New Zeland
Posts: 4
Thanks: 0
Thanked 2 Times in 2 Posts
Quote:
Originally Posted by MPaulHolmes View Post
I'm confused. must check my work. hahaha. Ya, sticking with scaling by 1024 is a good idea, since it matches the A/D resolution.
Sorry, did not intend to add confussion. Take home point was meant to be "Just do what you do, the compiler (should) make it faster for you."

The easier it is to read the better. I hate to think how many 100's of hours I have spent looking for minor little bugs in code the scientists and mathmaticians have made "faster" (what I term "permature optimisation").
  Reply With Quote
The Following User Says Thank You to MisterSid For This Useful Post:
MPaulHolmes (04-07-2014)
Old 04-07-2014, 09:44 AM   #6414 (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,362
Thanked 1,202 Times in 765 Posts
No it isnt you. I had written a dissertation about convergence rates of that method of taking the running average, and had made a mistake, so I erased all the stuff and just wrote "im confused".

You are absolutely right about premature optimization. Premature code optimization is the root of all programming evil.
__________________
kits and boards
  Reply With Quote
Old 04-07-2014, 11:08 PM   #6415 (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,362
Thanked 1,202 Times in 765 Posts
Rather than a specific current ramp rate in amps, I'm doing a "time to max current" sort of thing. You can pick any whole number between 1 and 8. 1 means 8 seconds to max current. 2 means 7 seconds to max current, ..., 8 means zero seconds to max current. 1 means 1 second from 0 to max motor amps, ... , 8 means 8 seconds to max motor amps.

EDIT!: THAT'S A LIE, i'M NOT DOING THAT ANYMORE!!!

Since motor amps are programmable, this seemed like a good idea. Motor amps can be anything in 1 to 1500 or so. I'm using 16 ounce copper. The 500amp controller uses 4 ounce copper, so I thought it would be OK.

By the way, I don't see a good way to keep perfect compliance with rtd explorer. For one thing, the max motor amps variable doesn't exist. I know Adam is planning on including max motor amps in his controller, so maybe it will be added to rtd. Also, the battery amp limit now needs 4 digits instead of 3. Well, in practice, there aren't too many batteries that will do over 1000 amps, but it would be a shame to have to limit what the controller could do.

I'm feeling really happy with the software rewrite. Everything feels pretty clean and understandable. The serial is just about done. Then I'll just add the eeprom write and read routines.

All the current variables in the saved data are in the units of amperes. So, no weird translations necessary to real amps from virtual amps.
__________________
kits and boards

Last edited by MPaulHolmes; 04-08-2014 at 08:20 AM..
  Reply With Quote
Old 04-08-2014, 02:12 AM   #6416 (permalink)
EcoModding Apprentice
 
Join Date: Oct 2010
Location: southland NZ
Posts: 153
Thanks: 38
Thanked 86 Times in 55 Posts
Hi Paul

I don't like your 1 - 8 scenario
Zero may be a little tricky and 1 second is a looong time when playing on the track,
I really don't see anybody wanting more than 1 second

How about going from
Zero to 8/10ths of a second?

I would want mine with 1/10th of a second to full current,
I think 8/10th would feel like a moderately slow response
  Reply With Quote
The Following User Says Thank You to duncan For This Useful Post:
MPaulHolmes (04-08-2014)
Old 04-08-2014, 07:05 AM   #6417 (permalink)
EV Connoisseur
 
Join Date: Aug 2010
Location: Amsterdam
Posts: 309
Thanks: 70
Thanked 109 Times in 90 Posts
Talking

Quote:
Originally Posted by duncan View Post
Hi Paul

I don't like your 1 - 8 scenario
Zero may be a little tricky and 1 second is a looong time when playing on the track,
I really don't see anybody wanting more than 1 second

How about going from
Zero to 8/10ths of a second?

I would want mine with 1/10th of a second to full current,
I think 8/10th would feel like a moderately slow response
I agree, why build such a powerful controller if you can't burn any rubber..
  Reply With Quote
The Following User Says Thank You to flores For This Useful Post:
MPaulHolmes (04-08-2014)
Old 04-08-2014, 08:00 AM   #6418 (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,362
Thanked 1,202 Times in 765 Posts
It was how the loop worked out. I'll sacrifice some cycles and make the 10ths of a second (or some variation thereof) work. Still, the PI loop isn't going to converge instantly, so I would certainly try a delay of zero, since it won't really be zero.

EDIT: OK that didn't take long! It will just add a single multiply and single bit shift. This will be no problem whatsoever. Then I can do it in increments of, say, 1/32sec, or whatever. Lots of flexibility. I was in thinking jail, and needed to be free. LOL.
__________________
kits and boards
  Reply With Quote
Old 04-08-2014, 08:20 AM   #6419 (permalink)
EV Connoisseur
 
Join Date: Aug 2010
Location: Amsterdam
Posts: 309
Thanks: 70
Thanked 109 Times in 90 Posts
by the way:

I've bought this: DC 0 200V 0 1000A Combo Meter Current Voltage Battery Monitor Charge Discharge | eBay measures voltage and amps, good value at 43$ I say. Good for monitoring the controller performance.
  Reply With Quote
The Following User Says Thank You to flores For This Useful Post:
MPaulHolmes (04-08-2014)
Old 04-08-2014, 09:33 AM   #6420 (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,362
Thanked 1,202 Times in 765 Posts
This is how it is now. Only one extra bit shift compared to before:

Let's say we have an instantaneous throttle step of 0 to MAXIMUM. Time to maximum current is as follows (c-rr is current ramp rate):
c-rr 1 means it reaches maximum current in 16 seconds. (16/1)
c-rr 2 means it reaches maximum current in 8 seconds. (16/2)
c-rr 3 means it reaches maximum current in 5.33 seconds. (16/3)
c-rr 4 means it reaches maximum current in 4 seconds. (16/4)
c-rr 5 means it reaches maximum current in 3.2 seconds. (16/5)
c-rr 6 means it reaches maximum current in 2.7 seconds. (16/6)
c-rr 7 means it reaches maximum current in 2.3 seconds. (16/7)
c-rr 8 means it reaches maximum current in 2 seconds. (16/8)
...
c-rr 16000 means it reaches maximum current in 1mS. (16/16000)
c-rr "anything bigger than 16000" is still 1mS, since the loop is executed at 1kHz.

__________________
kits and boards
  Reply With Quote
The Following 5 Users Say Thank You to MPaulHolmes For This Useful Post:
duncan (04-08-2014), flores (04-08-2014), jedsmd (04-08-2014), mpgmike (01-23-2022), thingstodo (04-08-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 3431 05-04-2022 06:43 PM
Paul & Sabrina's Cheap EV Conversion MPaulHolmes Fossil Fuel Free 542 11-12-2016 10:09 PM
Three Dirt Cheap DIY Electric Cars - Part 5 SVOboy EcoModder Blog Discussion 0 12-12-2008 05: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