DAC o/p capacitor query

I'm intending to use a 20M2 to read the position of mechanical throttle control lever using optical sensors and, having sensed the position, convert that to a (nominal) 0V to +5V analog output to control the speed of the 72V 20kW motor driving our 40' boat via the electronic controller (which has a 0 - 5V input). Needless to say, this is a safety critical application so I want it to be safe & reliable above all else!

On p.53 of the picaxe_manual2 the description of the DACSETUP command recommends an op-amp buffer which seems very sensible, together with a 100nF capacitor, presumably to smooth the output. That all looks fine until noting that the DAC output (on the 20M2, 14M2 & 8M2) is the same pin as Serial Out, used for programming the device. Presumably, this much capacitance on the pin will interfere with programming?

Is the best option to fit a jumper between the 100nF and the pin and remove it for programming? Or does anyone have a better suggestion?

Thanks in advance for all help.

Charles (retired electronic engineer, now boat restorer)
 

BeanieBots

Moderator
I'm sure you'll get plenty of comments on the "safety critical" side of things so I won't go there.

Why do you want to use the DAC output?
It has very limited resolution. (5-bit from memory)
I would suggest using PWM into the same 100nF which will give you 10-bit resolution and a similar time response.
 

premelec

Senior Member
Some more information please... do you now control this huge motor electronically? I wouldn't try developing such a controller from scratch - so many possible problems... however if you got a commercial controller which would take a small input control voltage that could work... Do you have a manual power disconnect switch in case of failure? There has been some discussion of getting DAC output from PICAXEs using PWMOUT and such - the DAC available is pretty rough... anyhow where are you in the design process - do you _only_ need a control signal or also a motor controller? If you are restoring what was the original controller [a carbon pile perhaps] ?
 

AllyCat

Senior Member
Hi,

Yes, I was just about to post the same as BB. Use PWM with a simple low pass output filter (perhaps 1k + 22uF) on any one of the PWM output pins.

Cheers, Alan.
 
Some more information please... do you now control this huge motor electronically? I wouldn't try developing such a controller from scratch - so many possible problems... however if you got a commercial controller which would take a small input control voltage that could work... Do you have a manual power disconnect switch in case of failure? There has been some discussion of getting DAC output from PICAXEs using PWMOUT and such - the DAC available is pretty rough... anyhow where are you in the design process - do you _only_ need a control signal or also a motor controller? If you are restoring what was the original controller [a carbon pile perhaps] ?
The motor controller (I already have) is a big(ish) box of very sophisticated electronics that takes the 72Vdc 500A supply from the battery pack(s) and converts it to a multi-phase AC supply to control the motor according to the low voltage inputs on a separate connector. There are several options to control the motor speed, the simplest being a 5k pot between the controller's +5V o/p and its Gnd, the wiper going to the speed control (forward/reverse are separate digital inputs). I have a suitable (very high quality) joystick type controller to use this function when steering from the back of the boat, but I also have a front steering position for which I want to use a 'period' brass speed controller (search for "davey engine control lever brass" to see it). Rather than try to hook this up mechanically to a pot, which might be prone to all sorts of problems, I thought an LED mounted on the arm, tracked with multiple cheap LDRs, would be a reliable way of sensing the lever's position. Nothing to go wrong mechanically at least. Converting the position, once measured with the PicAxe, to a voltage in the range 0V to +5V is an alternative (to a pot) that the controller box will understand.

The limited 5-bit resolution of the DAC output is not a problem; 31 variations in speed is way over what I probably need, I could probably get away with 3-bit (seven speeds) and I probably can't resolve the lever position to better than 4-bits anyway.
 

premelec

Senior Member
OK - seems like you might do best to simply switch a resistance string with the davey - and LDRs might work well - assuming you are dealing with salt water you want everything sealed up and clear plastic and LDRs could work - from what you say it would likely be best to NOT use a microcontroller - adds complications and more opportunity for failure. There are good magnetic [hall effect] switches also and simple reed switches in glass with a magnet to actuate... one problem is when you go from one position to next you probably don't want a dropout. There are proportional magnetic rotation sense units [Melexis and some others] which could work. Another possibility is an LDR with light shining through crossed polarizers which change in regard to handle position... temperature coefficients of LDRs are sometimes problematic. Tex wants to join you for initial in water tests... :)
 

premelec

Senior Member
Tex I think he wants you to go with him on the initial trouble shoot - with your educated hand on the cutoff for the 22HP motor - and your other hand on the fire extinguisher. I think we assume that he's interested in learning as well not into wrecking the boat. However we don't know what actual maritime experience he has and suggestion of due caution is appropriate. I'll bet there are $10 parts in Tesla's 600HP system that could make trouble... It's not so much the parts cost as the quality of the design...

"As goes the part so goes the whole" [sign seen on microfiche machine in auto parts store]
 

techElder

Well-known member
Yeah, just adding a bit of levity.

I'm hoping that the boat will be tested in a dry dock.

I've had a boat lose throttle control before. It starts out very confusing, then gets very serious! We don't want that to happen to this Hairy Animal! :)
 

premelec

Senior Member
yeah - he says he's a retired electronic engineer so he's not entirely innocent of what might happen -- I'd like to know more about the boat. It's probably easier to cut power from an electric motor than gasoline unit with a stuck throttle... or computer controlled stuck throttle...
 
yeah - he says he's a retired electronic engineer so he's not entirely innocent of what might happen -- I'd like to know more about the boat. It's probably easier to cut power from an electric motor than gasoline unit with a stuck throttle... or computer controlled stuck throttle...
Exactly right! The first thing I'll have is a 'neutral' button/switch that cuts the signal(s) from the PicAxe so that any form of surge due to dodgy inputs or programming, can be quickly eradicated. But that's not enough, as a previous restorer of the boat discovered just after relaunching - they applied full throttle (big diesel engine) and got the boat moving, only to have it cut out immediately as they hadn't filled the fuel tank. With no engine there was no braking and they hit the far side of the waterway quite hard causing damage that (30 years on) we've now repaired.

So the next thing I'll have is an emergency reverse push button (non latching), to override any other states and provide some stopping capability.

While costs are always important, my overriding concern is to keep it simple mechanically to minimise the risk of malfunction, and similarly with the electronics and programming.

One advantage of using a PicAxe to convert the lever position to a control voltage (as opposed to direct electronics) is that it will be easy to provide a non-linear transfer function. Once the boat's in the water, I might well find that I need finer control over the lower speeds, and will only occasionally use max throttle/speed.

For the record, the boat is roughly 40' x 7' and designed for inland waterways (no seawater involved) and will probably weigh about 6 tons. The electronics for this (as with other PicAxe designs I'm making for it) will be enclosed in a sealed plastic enclosure and I'll make/buy a gaiter for the lever where it exits the box, so all the components should be protected from any rain or spray.
 

techElder

Well-known member
That does sound like a cruiser!

Ok, so don't reinvent the wheel. Find a really good sealed "pot"; something from the automotive industry; say something that might have been designed for the accelerator on a vehicle.

Then use ADC on the PICAXE to read said "pot".

Then use a program in said PICAXE to point those ADC readings to TABLE values.

Then use said TABLE values to control a PWM output to create whatever control voltage you need.

You could filter / convert said PWM to smooth it into a fixed DC value if necessary.

Then, "Bob's your uncle!"

Yer ready to go cruisin'!
 

hippy

Technical Support
Staff member
Rather than try to hook this up mechanically to a pot, which might be prone to all sorts of problems, I thought an LED mounted on the arm, tracked with multiple cheap LDRs, would be a reliable way of sensing the lever's position. Nothing to go wrong mechanically at least.
I would have thought a simple mechanical linkage to a good quality pot would actually have less potential for going wrong, would be far easier to fix if anything did.

Putting aside the safety issues it is a 'how to generate a variable voltage form an adjustable lever' project.
 

Goeytex

Senior Member
Returning to Charles' original question since no one seemed to address it ...

Is the best option to fit a jumper between the 100nF and the pin and remove it for programming? Or does anyone have a better suggestion?
A jumper to bypass the cap/opamp during programming is probably the best method. It is simple and easy to implement. Another (less desirable) alternative is to remove the chip and do the programing on a breadboard or other programming platform, but then you risk damaging the pins with repeated removals and insertions.

As far as the reliability of a mechanical linkage to a pot. A well designed and well made linkage should easily outlast the Pot itself. Using a high quality IP66/67 rated pot would also substantially simplify the electronics. (No LEDS, no LDRs, no OPAMP and no Programing Jumper).

If you still choose to use the DAC, make sure you select an OPAMP that supports rail-to rail inputs and outputs. Otherwise the signal will never be fully off (0v) or fully on (5V)
 
Returning to Charles' original question since no one seemed to address it ...

A jumper to bypass the cap/opamp during programming is probably the best method. It is simple and easy to implement. Another (less desirable) alternative is to remove the chip and do the programing on a breadboard or other programming platform, but then you risk damaging the pins with repeated removals and insertions.

As far as the reliability of a mechanical linkage to a pot. A well designed and well made linkage should easily outlast the Pot itself. Using a high quality IP66/67 rated pot would also substantially simplify the electronics. (No LEDS, no LDRs, no OPAMP and no Programing Jumper).
Thanks for confirming my thoughts on the jumper - most helpful.

Agreed a good quality sealed pot (I already have suitable devices) would be the best way to go, but it gets a bit difficult to convert the limited arc of movement of the motor lever to turn a pot. The lever moves by 90° total, of which 45° is in the reverse direction from the neutral (central) position, and 45° in the forward direction. In each arc, the end hole on the arm moves less than 2" (arc, the chord is less) and I'd need it to turn the pot (preferably) full range (270°?) whichever direction it was moved from the centre position, and in addition, I'll need another sensor (microswitch or whatever) to detect forward/reverse.

Getting reliably from the one movement to the other I decided was going to tax my mechanical skills, hence the decision to go optical using an arc of LDRs with a low power LED moving across them. The idea being that at any given position, the LED will illuminate two or three LDRs, and using three ADC inputs, strobed across the sensors via 4066 analog switches, I can get an average position for the LED (and hence the arm) with greater accuracy than would be the case with discrete sensors such as reed switches. The cheap but readily available LDRs I can get from eBay are about 1/4" across, so I can only get eight of them into the 2" arc for forward or reverse, which is just a little bit too coarse. Averaging between them to get about 15/16 positions should be ample. Most of the time we'll be cruising with the motor at one comfortable speed and will rarely need to change it or get a more subtle change in speed - it's not like a road vehicle where fine control of the speed is very important.

So, as I mentioned previously, the DAC accuracy is adequate, though the PWM approach is a good alternative and worth considering.

It's most helpful having such an exchange of ideas on this forum as people bring up suggestions I hadn't thought of. Thanks all.
 

Goeytex

Senior Member
Thanks for confirming my thoughts on the jumper - most helpful.
Agreed a good quality sealed pot (I already have suitable devices) would be the best way to go, but it gets a bit difficult to convert the limited arc of movement of the motor lever to turn a pot. The lever moves by 90° total, of which 45° is in the reverse direction from the neutral (central) position, and 45° in the forward direction. In each arc, the end hole on the arm moves less than 2" (arc, the chord is less) and I'd need it to turn the pot (preferably) full range (270°?) whichever direction it was moved from the centre position, and in addition, I'll need another sensor (microswitch or whatever) to detect forward/reverse.
If we assume the pot is supplied 5 volts, then the center position will be 2.5 volts at the center.
Therefore 2.5 volts represents "OFF".

Can we then assume if the pot is moved full range that 5v is full speed forward and 0V is full speed reverse?

When using a micro there is no need to move the pot full range. Connect the pot to a 10bit ADC input and the digital output will be a full range value from 0 to 1024 where 0 is 0 degrees and 1024 is 270 degrees. However if the pot movement is limited to say 90 degrees ... we still have a range of 340 ADC units where:

Center = 512
Full Forward = 682
Full Reverse = 342

If we mechanically position the pot we can get an ADC range of 0 to 340

The Picaxe can then convert this to whatever we want using simple maths

For example:
If the value is between 160 and 180 then turn the motor off (center Position)
If the value is from 181 - 340 then Output a PWM that represents 0v - 5v for Forward
If the value is from 159 - 0 then Output a PWM that represents 0V - 5V for Reverse

All done with simple maths in the Picaxe.
 
Last edited:

techElder

Well-known member
The one thing about "simple" maths is that they become less "simple" when customization is necessary, and the simpler they are the less adjustable they are.

That's why I suggested the TABLE lookup option in post #13. Adjust the numbers to fit your custom curve.

There couldn't be that many numbers to fit a curve where the DAC output would be "adequate."
 

hippy

Technical Support
Staff member
As Goeytex notes, limited rotation of a pot should not be a problem, and by using the ADC Vref+ option you could still get near maximum 1024 step resolution over that limited range.

The mechanics should not be that hard. Either a Z-like linkage to the pot, or have a tuning fork shaped spur from the pot shaft which a lug at the end of the lever sits in.

I would say using PWMOUT and an RC circuit rather than DAC was the best way to avoid issues of dual pin use and avoids having ( and needing to move ) links for programming.
 
As Goeytex notes, limited rotation of a pot should not be a problem, and by using the ADC Vref+ option you could still get near maximum 1024 step resolution over that limited range.

The mechanics should not be that hard. Either a Z-like linkage to the pot, or have a tuning fork shaped spur from the pot shaft which a lug at the end of the lever sits in.

I would say using PWMOUT and an RC circuit rather than DAC was the best way to avoid issues of dual pin use and avoids having ( and needing to move ) links for programming.
Hmm, those helpful suggestions for a linkage mechanism have got me thinking that you're right, it may not be as difficult as I'd thought, and indeed, I wouldn't need to use the full range of the pot. I will most certainly revisit the design and see if I can use a nice simple pot with Pic interpretation of the levels.

Thanks all.
 
The mechanics should not be that hard. Either a Z-like linkage to the pot, or have a tuning fork shaped spur from the pot shaft which a lug at the end of the lever sits in.
Thanks hippy. I took your advice and tried the 'tuning fork' approach and with some careful design/planning and a bit of basic metalwork, I've got what I hope will be a very satisfactory solution. See here and here for pictures. I've also put a little bit of video showing the movement here on YouTube.

The pot is a mil-spec sealed type (albeit Russian mil-spec!!) and measures about 60k instead of the 47k it's supposed to be, but for my purposes that doesn't matter in the slightest. The full mechanical movement gives me about 50% of the pot's range from roughly 25% to 75%, which is fine and will give adequate resolution using the suggestions given above.

Now I need to figure out a way of measuring the position of a spindle that revolves 1¼ turns (450°) with a pot that turns 270° in order to get a rudder position indicator as previously described elsewhere on this forum, using a very elegant solution with an r/c servo as the indicator.
 

premelec

Senior Member
@Hairy... strings and wheels - or fine cable like old style sliderule dials used- BTW many years ago when I was testing wear on various Pots I found that the molded carbon track Allen Bradly [AB] types got better with exercise as far as electrical noise. There are lots of these surplus... the shaft bearing friction was not as good as the electrical track in wear characteristic...
 
Top