Alter a square wave signal? - Page 1
Forum section: electronics / beginners

author: cittra49
author_rank: Newbie
timestamp: March 08, 2021, 02:00:44 pm
content: I want to alter a square wave signal from a speed sensor on a cadillac, i have changed tires to 20" rims, stock is 16" so the speedometer is off, the GM tech2 scanner cant change to so big wheels. So i thought why not fool the computer by altering the hertz of the speedometer signal.Best would be if the increase / slowing the hertz would be adjustable so i could calibrate the speed by help of the radar signs at the road that tells you the speed.

author: Terry Bites
author_rank: Super Contributor
timestamp: March 08, 2021, 04:27:59 pm
content: You could use an Arduino or similar microcontroller eghttps://www.google.co.uk/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&ved=2ahUKEwj2kL-wiqHvAhV1oVwKHReyDqcQFjACegQIAxAD&url=http%3A%2F%2Fww1.microchip.com%2Fdownloads%2Fen%2FAppnotes%2Fdoc8365.pdf&usg=AOvVaw062jxNbT_lsEJuR9tjd2JUand a few lines of code. This will be able to give very high accuracy conversion in a very short time.Or use a frequency to voltage to converter followed by a voltage to frequency converter. This is easier to tweak on the fly but will be a slower to respond and not as accurate as the micro. Still, as you don't have the acceleration of an X-15 its probably not an issue. 1% is good enough. A pair of LM331's will do F/V and V/F.https://www.ti.com/lit/gpn/lm331.It will probably end up more expensive than the micro, but it'll be much more fun.

author: rstofer
author_rank: Super Contributor
timestamp: March 08, 2021, 05:06:45 pm
content: Many years ago there were speedometer shops and they had little add-on gear boxes for this kind of thing. But way back then, speedometers were mechanical and the speedo shaft turned about 1000 revs per mile. Some vehicles were 800 revs per mile.I was messing about with time-distance-error calculations/displays for sports car rallies back in the early '70s and we needed better than 0.01 mi / <some large distance>. We didn't care about accuracy, we needed our odometer to match the rally master's so we had to accomodate some variation in the revs per mile. Thumb wheel switches came to mind. It would be a few years before uCs invaded the space.I wonder if speedometer shops are still a thing.

author: Benta
author_rank: Super Contributor
timestamp: March 08, 2021, 06:05:47 pm
content: Changing the rims doesn't necessarily change tire circumference. The tires just get a lower profile.Please tell us if this is or isn't the case.

author: Stray Electron
author_rank: Super Contributor
timestamp: March 08, 2021, 07:02:16 pm
content: Quote from: cittra49 on March 08, 2021, 02:00:44 pmI don't about Cadillacs particularly the newer ones but on the old Chryslers (& Dodge and Plymouth), the speedometer was operated by a gear on the end of the flexible speedometer cable and just inside the transmission. You could remove one easy to reach bolt, pull the gear and it's housing out of the transmission, unplug the gear and plug in a new one with a slightly different number of teeth, then plug it all back into the transmission, reinstall the bolt and that was it.In the modern Ford trucks with the electronic dash you can change the SW settings to adjust for tire size. Look up the "Forscan" for a cheap and easy use system. (Forscan.org) Basically all you have to do is to Poke a different value into a certain memory location. Then see if there is something similar for the modern Cadillac.

author: fordem
author_rank: Regular Contributor
timestamp: March 08, 2021, 07:22:39 pm
content: Quote from: cittra49 on March 08, 2021, 02:00:44 pmJaycar sell a commercial product to do this - about USD$50, which I suspect is less than you can build it for yourself, so unless you have a particular interest in building your own, I don't see the point. Check with the 4WD shops in your country or buy it online.

author: mikerj
author_rank: Super Contributor
timestamp: March 08, 2021, 09:24:23 pm
content: Another commercial product is the "Speedohealer" made by Healtech, primarily designed for motorcycles but no reason it wouldn't work on a car. These units are very commonly used as changing the final drive sprocket sizes on many bikes will throw out the speedometer, not particularly cheap new but often found s/h on eBay etc.

author: cittra49
author_rank: Newbie
timestamp: March 08, 2021, 10:13:17 pm
content: TY for all the answers, the Cadillac is 1996 model, the gearbox have a ring inside like a abs ring so that is very hard to change, since the Cadilac is FWD with a V8, to get to the tranny you need to lower the whole subframe. I wasnt aware that there where commercial options, i havent fount anything with my poor google skills, but ill look into the products.The speed differance now is about 10% wrong, and i have used a GM scanner called tech2 to alter the tire dimensions and set it to the biggest option there but it isnt enough.

author: Terry Bites
author_rank: Super Contributor
timestamp: March 09, 2021, 01:52:06 pm
content: Speedo Corrector, Mk.3 - September 2013https://www.siliconchip.com.au/Issue/2013/September/Speedo+Corrector%2C+Mk.3$8 for plans and software.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: March 09, 2021, 02:11:44 pm
content: If you want to do it in software...The Bresenham algotrithm is perfectly suited for this, can be very accurate, and is easy to understand and implement.It works like this in Python:```BigNum = 1286SmallNum = 238Accu = 0for x in range(30):print( Accu)Accu += SmallNum;if( Accu > BigNum):print( "\t\tBingo")Accu -= BigNum`````The output cycles between 5 or 6 loops, and the frequency between those two depends on the numbers.Normally for "BigNum" a very big number is used, (Such as 2^^32) but with a bit of headroom for "overflow".The output of the above example is:```02384767149521190Bingo1423806188561094Bingo462845227609981236Bingo1884266649021140Bingo9233056880610441282Bingo234472```

author: Nominal Animal
author_rank: Super Contributor
timestamp: March 10, 2021, 06:48:10 am
content: Quote from: Doctorandus_P on March 09, 2021, 02:11:44 pmIt may be easier to treat it as aDigital differential analyzerinstead. (The technical or mathematical differences are neglible here; I only mean that as a differential analyzer the approach is easier to understand and work with.)Digital differential analyzer is a fancy name for accumulators whose overflow (or "carry") indicates an output event – a high pulse in the case of pulse density modulation, or a diagonal step (instead of a straight one) when rasterizing lines, and so on.The root idea is anyway the same as for a 2D line, except the two axes are now both time: one is input time axis, and the other is output time axis. The slope of the "line" is the ratio of input time to output time – or, in the case of pulses, the number of input pulses to output pulses.In the pulse count adjusting case, one detects say rising edges, and forNrising edges generate onlyMrising edges, withM≤N. This is stupidly simple to implement even in a pin change interrupt handler – the biggest "problem" is to manage the opposite edge of the output pulse –, and amazingly accurate considering how little resources it takes to implement. However, the restrictionM≤Nis a "hard one", and comes from the fact that each input event can generate at most one output event. In computer graphics speak, withM>Nyou get holes in your line.When the tire diameter is larger than expected, the number of pulses from the drive train underestimates the distance traveled, so you actually need to generatemorepulses, notfewer. So, we're firmly in theM>Nland, and a pure free-running Bresenham/DDA pulse (edge) generator alone won't work.Instead, a microcontroller implementation would need to be a pulse generator, whose pulse interval is adjusted based on the input pulse intervals. This is very similar to implement – not difficult at all even with simple AVR microcontrollers –, but with a core difference: the input and output are connected only by the control variable, and not by physical events. Usually, there is a small time delay, so that the output pulse rate is calculated based on more than one input pulse interval. Mathematically or design wise, it also matters whether we only care about the pulse frequency, or also about the total pulse count (for the odometer) – but this is more about where we can ignore "rounding errors" and where we need to consider more details, nothing "hard" per se.The output side can be either PWM (with a small duty cycle, adjusting the base frequency instead), or use pulse density modulation with a simple DDA/Bresenham with less than 50% duty cycle, to generate a very stable and nicely behaving, but very responsive output pulse train. The input side is a basic pulse frequency or interval detector, with its time base tied to the time base of the output side, but otherwise free running (does not need to be calibrated at any specific frequency or anything, since the output is ratiometric; i.e. the number of output pulses inany given intervalis a specific constant ratio of the number of input pulses). If you have a microcontroller without interruptions running at say 10× or higher frequency (of main loop iterations, not instructions per second!) than the maximum input or output pulse rate, this can be made rock solid; one trick I'd like to see used is tracking transitions (both edges of the pulses), as then the state machine becomes amazingly simple.(Personally, I'd implement this in two different parts: one being the pulse frequency unit itself, with just a standard ICSP connector, and the other reprogramming it whenever the ratio needs adjusting or calibrating, with a small display and a couple of buttons, to adjust/set the new ratio of speeds or distances.)The problem is making it automotive grade, electronically! Paying $50 for something thatoughtto be, doesn't sound bad at all to me.

author: fordem
author_rank: Regular Contributor
timestamp: March 11, 2021, 02:01:39 am
content: Quote from: Nominal Animal on March 10, 2021, 06:48:10 amI cannot vouch for the "suitability for purpose" of the Jaycar product as I have not used it personally, they did offer it as a "build-it-yourself" kit, and I have assisted two members of 4WD forums I've on to get their kits sorted as well as work out which wires on their cars to connect it to - I do happen to own the vehicles they did, and have the factory manuals for them. The kit allows for both smaller & larger tires.No one has mentioned down the road failures to me.

author: Nominal Animal
author_rank: Super Contributor
timestamp: March 11, 2021, 02:45:51 am
content: Quote from: fordem on March 11, 2021, 02:01:39 amYes, I understand, and that's why I emphasized the "ought" part. Automotive is quite a harsh environment, what with supply voltage variances, spikes, noise, and brownouts.I've looked at automotive ATX power supplies for in-car PCs (in particular, themini-box M4-ATXand their earlier versions), and for a relatively straightforward DC-DC supplies, they show how much logic is needed to do it right... Compare to e.g. aPicoPSU, intended to be used with a regulated 12 VDC power supply. Granted, that's a rather extreme case, complexity and sensitivity wise.Even though the pulse train adjuster only needs something like perhaps a couple of dozen of milliamps (and most of it to drive the output signal), it'd need to be relatively impervious to those power supply variances and spikes and noise, and how to do that effectively and efficiently is definitely an engineering issue that needs practical experience.(It'd make for an excellent topic if one of the greybeards were willing to describe their experiences and practical knowledge.)