Author Topic: Alter a square wave signal?  (Read 1387 times)

0 Members and 1 Guest are viewing this topic.

Offline cittra49Topic starter

  • Newbie
  • Posts: 5
  • Country: se
Alter a square wave signal?
« on: March 08, 2021, 02:00:44 pm »
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.

 

Online Terry Bites

  • Super Contributor
  • ***
  • Posts: 2398
  • Country: gb
  • Recovering Electrical Engineer
Re: Alter a square wave signal?
« Reply #1 on: March 08, 2021, 04:27:59 pm »
You could use an Arduino or similar microcontroller eg https://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_lsEJuR9tjd2JU and 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.

 

Online rstofer

  • Super Contributor
  • ***
  • Posts: 9890
  • Country: us
Re: Alter a square wave signal?
« Reply #2 on: March 08, 2021, 05:06:45 pm »
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.
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 5880
  • Country: de
Re: Alter a square wave signal?
« Reply #3 on: March 08, 2021, 06:05:47 pm »
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.

 
The following users thanked this post: tooki

Offline Stray Electron

  • Super Contributor
  • ***
  • Posts: 2052
Re: Alter a square wave signal?
« Reply #4 on: March 08, 2021, 07:02:16 pm »
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.

  I 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.
 

Offline fordem

  • Regular Contributor
  • *
  • Posts: 234
  • Country: gy
Re: Alter a square wave signal?
« Reply #5 on: March 08, 2021, 07:22:39 pm »
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.

Jaycar 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.
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3240
  • Country: gb
Re: Alter a square wave signal?
« Reply #6 on: March 08, 2021, 09:24:23 pm »
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.
 

Offline cittra49Topic starter

  • Newbie
  • Posts: 5
  • Country: se
Re: Alter a square wave signal?
« Reply #7 on: March 08, 2021, 10:13:17 pm »
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 :D , 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.
 

Online Terry Bites

  • Super Contributor
  • ***
  • Posts: 2398
  • Country: gb
  • Recovering Electrical Engineer
Re: Alter a square wave signal?
« Reply #8 on: March 09, 2021, 01:52:06 pm »
Speedo Corrector, Mk.3 - September 2013
https://www.siliconchip.com.au/Issue/2013/September/Speedo+Corrector%2C+Mk.3
$8 for plans and software.
 

Online Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3367
  • Country: nl
Re: Alter a square wave signal?
« Reply #9 on: March 09, 2021, 02:11:44 pm »
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      = 1286
SmallNum   = 238
Accu      = 0

for 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:
```
0
238
476
714
952
1190
      Bingo
142
380
618
856
1094
      Bingo
46
284
522
760
998
1236
      Bingo
188
426
664
902
1140
      Bingo
92
330
568
806
1044
1282
      Bingo
234
472
```
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6266
  • Country: fi
    • My home page and email address
Re: Alter a square wave signal?
« Reply #10 on: March 10, 2021, 06:48:10 am »
The Bresenham algotrithm is perfectly suited for this, can be very accurate, and is easy to understand and implement.
It may be easier to treat it as a Digital differential analyzer instead.  (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 for N rising edges generate only M rising edges, with MN.  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 restriction MN is a "hard one", and comes from the fact that each input event can generate at most one output event.  In computer graphics speak, with M > N you 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 generate more pulses, not fewer.  So, we're firmly in the M > N land, 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 in any given interval is 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 that ought to be, doesn't sound bad at all to me.
 

Offline fordem

  • Regular Contributor
  • *
  • Posts: 234
  • Country: gy
Re: Alter a square wave signal?
« Reply #11 on: March 11, 2021, 02:01:39 am »
The problem is making it automotive grade, electronically!  Paying $50 for something that ought to be, doesn't sound bad at all to me.

I 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.
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6266
  • Country: fi
    • My home page and email address
Re: Alter a square wave signal?
« Reply #12 on: March 11, 2021, 02:45:51 am »
I 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
Yes, 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, the mini-box M4-ATX and 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. a PicoPSU, 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.)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf