work in progress VW 1980 aircooled Vanagon

Your chance to introduce yourself and your vehicle
Post Reply
User avatar
camperbonde
Posts: 10
Joined: Tue Nov 17, 2015 7:50 am
Location: Sweden

VW 1980 aircooled Vanagon

Post by camperbonde »

Hi there!
Originally I wanted to replace the old system with a more modern C.O.P. system based on denso type coils and injectors.
My 2.0 litre aircooled engine is down into it's subatomic parts due to a total overhaul. Have to use the original hardware to run in the cam etc....
Then:
My thoughts were to "record" what the original injection system (analog) is doing and implement it in a modern embedded processor.
I was recommended to use an already existing ecu system i.e. megasquirt..... but modern cpu?....floating point?...nay!

There's a lot of STM32 minimum boards on aliexpress (10-20$) so I looked around for someone that was using them..... and here I am!

An old engine design = no cam sensor a tdc sensor does exist but only for diagnostics the injection system only aware of rpm not synced to rotation etc....
the only thing in sync is the distributor.
I dont like toothed wheels, hall sensors because for the worst case it takes one full engine turn before sync.
There is another approach that always knows the engine position even at standstill, a hall effect angle sensor. Basically a radially magnetised disc replacing the distributor
and a sensor chip that outputs two sinewaves good for 100k rpm's. With reasonable AD and a good lookup table fractions of a degree are possible.
So I also have one question: Is the rusEFI able to calculate arctan at high speed?
Or should another processor do that and communicate via a highspeed interface? 12 bit precision is enough = 0.088 degree?
"Nihil humani a me alienum esse" T. Brahe
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: VW 1980 aircooled Vanagon

Post by AndreyB »

Hello and welcome!

Please note that rusefi runs of stm32f4, the majority of cheapest boards are stm32f0 or f1. F4 discovery board is cheap as well :)

The problem with angle lookup would be less about complexity of lookup and more about the fact that rusefi code depends onangle notifications at given angles - rusefi code needs events to be pushed into it, it does not know how often and when to request angle position. So, to use this code you would need a more traditional sensor.
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
kb1gtt
contributor
contributor
Posts: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

Re: VW 1980 aircooled Vanagon

Post by kb1gtt »

I agree the arctan shouldn't be an issue. If you are conserving CPU cycles it can be done with a pinch of memory for a lookup table, or if you have the CPU cycles to spare you can use a math function. The real issue is that the existing algorithm uses IRQ edge triggers on each pulsed edge. I don't believe the angular sensor would produce this kind of edge trigger, so it wouldn't create the trigger needed by the software. I believe that would also be a problem for MS and other ECU's. On a bonus, rusEFI being open, allows you the option of developing it if you so choose. However MS and several others don't allow that option.
Welcome to the friendlier side of internet crazy :)
User avatar
abecedarian
Posts: 386
Joined: Fri Nov 15, 2013 10:49 am

Re: VW 1980 aircooled Vanagon

Post by abecedarian »

AMS has several magnetic position sensors that provide various outputs like SPI angle reporting, quadrature ABI, analog voltage and PWM signals. One of their quadrature might be made compatible with rusefi as they output some number of pulses per revolution per channel (A + B). Some of those can be programmed to a known magnetic flux / position calibration to give an indexed position signal.

Deeper thought... one that supports both digital and ABI, like AS5045B (12 bit) or AS5047D (14 bit), could be setup to a known position, and then queried by the MCU for current position on power-on, then the controller could use A or B channel from the quadrature decoder to get a pulse train for actual engine operation, and the I(ndex) signal for re-synch if necessary. Something like this could be mounted under a dummy distributor cap and work off the distributor shaft, or on the Type-IV, off the end of the crankshaft inside the squirrel cage.
You can lead the horticulture but you can't make them think.
User avatar
kb1gtt
contributor
contributor
Posts: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

Re: VW 1980 aircooled Vanagon

Post by kb1gtt »

I wonder if a software timer could be set to repetitively trigger, then grab the value and stick it in the crank angle variable. Getting the analog value into the code such that other stuff can do it's thing would be the trick. This would be a significant re-design of a crank decoder.
Welcome to the friendlier side of internet crazy :)
User avatar
abecedarian
Posts: 386
Joined: Fri Nov 15, 2013 10:49 am

Re: VW 1980 aircooled Vanagon

Post by abecedarian »

kb1gtt wrote:I wonder if a software timer could be set to repetitively trigger, then grab the value and stick it in the crank angle variable. Getting the analog value into the code such that other stuff can do it's thing would be the trick. This would be a significant re-design of a crank decoder.
You didn't read a word I said nor look up the chips I mentioned, did you?


Anyhow, a software timer tick, queue up SPI, send words, read words and stuff into memory / variables sounds to me to be a lot slower than reading pin changes from a chip... like one would do with a crank / trigger wheel decoder, which when running would be just about what I suggested.

*edit- yes it would be an additional crank decoder, but not so extreme as what you imply.
You can lead the horticulture but you can't make them think.
User avatar
kb1gtt
contributor
contributor
Posts: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

Re: VW 1980 aircooled Vanagon

Post by kb1gtt »

I'm familiar with AMS chips http://jaredharvey.com/Files/projects/open-encoder/index.htm Of course their hall sensors can be mounted near your flywheel teeth to get crank info, and you could add one to the cam to get your TDC information.

Quadrature encodes don't indicate TDC and are relative sensors not absolute sensors. As well 14 bits of angular pulses is likely to many pulses, it would likely start to load down the CPU cycles. We know the 60 tooth wheel is OK, which if you could make a quadrature work some how, would be a near equiv of 6 bit accuracy, as well a typical 36 wheel would be an near equiv of 5 bit.

The point that camperbonde was trying to inquire about wasn't how to find a way to make a different pulsed sensor that indicates shaft angle, it was an inquiry about how or if you could use an absolute analog signal. The issue is that the absolute analog (whether be obtained by SPI, ADC, or what ever other approach) is that it doesn't currently work well with the general algorithm. He has embedded skills so it could potentially be modified, but currently it doesn't play nice.
Welcome to the friendlier side of internet crazy :)
User avatar
abecedarian
Posts: 386
Joined: Fri Nov 15, 2013 10:49 am

Re: VW 1980 aircooled Vanagon

Post by abecedarian »

kb1gtt wrote:I'm familiar with AMS chips http://jaredharvey.com/Files/projects/open-encoder/index.htm Of course their hall sensors can be mounted near your flywheel teeth to get crank info, and you could add one to the cam to get your TDC information.
Apparently you're not familiar with the chips I posted. The chips I posted ARE THE HALL SENSORS and mount no where near flywheel teeth. They sense a rotating magnet on the end of a shaft with the sensor perpendicular to the shaft.

Please do your due diligence when researching parts before forming arguments and/or opinion that don't serve you well.
You can lead the horticulture but you can't make them think.
User avatar
camperbonde
Posts: 10
Joined: Tue Nov 17, 2015 7:50 am
Location: Sweden

Re: VW 1980 aircooled Vanagon

Post by camperbonde »

I think that using another processor for this would be simpler, the chip I was considering is sentron 2SA-10.
The AS5115 would also be suitable.
It does signal conditioning and has sine-cos outputs, with 2ch AD and a 1 cycle division with an lookup table, you'll get 0.1 degree resolution.
Most of the other more advanced chips takes a lot of time before they have a value (calculating cordic alg. etc. 30us has passed).
With 2 channels of sampling at 1MHz from a stm32f103 generating a signal like from a toothed wheel would be a piece of cake.
But i wanted the fastest possible engine startup, that seems to be hard to get with the current software.
I kind of liked the idea that the ECU knows where the engine is at startup.
Old style engines when properly adjusted could start immidiately, seems like modern with ecu's take a couple of turns before starting.

(I ordered both f4 and f1 minimum boards. I just selected some with 2.54mm division between pins for simple interfacing.)

edit: If its event driven it seems feasible to use my sensor approach, using a low level high priority interrupt every us or maybe less often, and setting the "teeth" interrupt flags from it.
Instead of using edge triggered inputs. But that depends upon how the other analog inputs are used and how interrupt priority levels are implemented in the processor.
"Nihil humani a me alienum esse" T. Brahe
User avatar
abecedarian
Posts: 386
Joined: Fri Nov 15, 2013 10:49 am

Re: VW 1980 aircooled Vanagon

Post by abecedarian »

camperbonde wrote:...
If its event driven it seems feasible to use my sensor approach, using a low level high priority interrupt every us or maybe less often, and setting the "teeth" interrupt flags from it.
Instead of using edge triggered inputs. But that depends upon how the other analog inputs are used and how interrupt priority levels are implemented in the processor.
Problems might start with the overhead used in servicing the interrupts necessary to get the position data from the external controller.

My solution only used SPI to get initial position data from the AMS chip when the system powers up to satisfy your "known position" when starting, then falls back to using the A or B pulse stream from the chip to work out position when the engine is running, much like a traditional crank position sensor. A possible use of the "I" / index signal is to re-synch with a known position: use the "I" pulse to ignore one or more pulses from the A or B output so as to artificially generate missing teeth. An ATMEGA328 (Arduino Uno) could run this, for what it's worth.
You can lead the horticulture but you can't make them think.
User avatar
kb1gtt
contributor
contributor
Posts: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

Re: VW 1980 aircooled Vanagon

Post by kb1gtt »

Oops, my web page doesn't link to the real data, it's just vague pretty pictures. This link has more information about those pictures.

http://openservo.com/forums/viewtopic.php?t=940

Some comments, these chips need the magnetic flux to be between a reasonably small windows of tesla's. The examples that AMS (or what ever MFG) offers often don't include the effects of physically mounting the magnet. As well they generally show the magnet from the top instead of from the bottom. The ASIC inside is often closer to one side of the black potting materiel. In my case I was modifying a pot, and I ended up using a design with a hole drilled down the center of the magnet. The effects of this small hole changed the resulting magnetic flux at the sensor. If your flux is to small, it no worky, if it's to strong it no worky. I was able to accurately enough predict the magnetic flux that was able to get the chips flux reading in the proper window. I predicted the fluc with a program known as FEMM. The results from FEMM are what is shown in the pretty pictures on my web page.

Another critical item with these chips is that they need to be significantly axially aligned. Again if you are off center by a small margin, it no worky. What I did was to have the PCB made with a magnet sized hole cut below the chip. The chip has to be well aligned to land on the PCB pads, then the magnet is put in the hole below the chip and it aligns the magnet with the chip. It was a simple design that you might want to consider. With out it, alignment of the magnet and chip can be a bugger.

That project was done in KICAD and communicated with the AVR via I2C. The code is posted and open source. The chip I used for that might not allow for fast enough RPM's for engine applications, but many of the design steps might be of interest. Keep in mind that I2C, SPI, or most protocols will have a delay. The delay will shift you real world readings by a bit, but it might be negligible, or it might need to be compensated for in software.

Building such a sensor into a module which then mimic a different crank wheel will likely have the same sync issues, as the crank decoder will still need to sync. If you pursue such an approach, I think you'll have to make modifications to rusEFI. I seem to recall the crank decoder updates some variables like a RPM variable and a timer that's used to create crank ticks based on crank angle. You could probably write a different decoder that get's the data from the chip and updates these variables. If you study the rusEFI code you'll probably find it's not as scary as you might thing. However keep in mind you are the only one with the hardware and the only one who will have the ability to decode such a system. I can offer some help with the hardware stuff, but I'm weak when it come to code.
Welcome to the friendlier side of internet crazy :)
User avatar
abecedarian
Posts: 386
Joined: Fri Nov 15, 2013 10:49 am

Re: VW 1980 aircooled Vanagon

Post by abecedarian »

kb1gtt wrote:Oops, my web page doesn't link to the real data, it's just vague pretty pictures. This link has more information about those pictures.

http://openservo.com/forums/viewtopic.php?t=940

Some comments, these chips need the magnetic flux to be between a reasonably small windows of tesla's. The examples that AMS (or what ever MFG) offers often don't include the effects of physically mounting the magnet. As well they generally show the magnet from the top instead of from the bottom. The ASIC inside is often closer to one side of the black potting materiel. In my case I was modifying a pot, and I ended up using a design with a hole drilled down the center of the magnet. The effects of this small hole changed the resulting magnetic flux at the sensor. If your flux is to small, it no worky, if it's to strong it no worky. I was able to accurately enough predict the magnetic flux that was able to get the chips flux reading in the proper window. I predicted the fluc with a program known as FEMM. The results from FEMM are what is shown in the pretty pictures on my web page.

Another critical item with these chips is that they need to be significantly axially aligned. Again if you are off center by a small margin, it no worky. What I did was to have the PCB made with a magnet sized hole cut below the chip. The chip has to be well aligned to land on the PCB pads, then the magnet is put in the hole below the chip and it aligns the magnet with the chip. It was a simple design that you might want to consider. With out it, alignment of the magnet and chip can be a bugger.

That project was done in KICAD and communicated with the AVR via I2C. The code is posted and open source. The chip I used for that might not allow for fast enough RPM's for engine applications, but many of the design steps might be of interest. Keep in mind that I2C, SPI, or most protocols will have a delay. The delay will shift you real world readings by a bit, but it might be negligible, or it might need to be compensated for in software.

Building such a sensor into a module which then mimic a different crank wheel will likely have the same sync issues, as the crank decoder will still need to sync. If you pursue such an approach, I think you'll have to make modifications to rusEFI. I seem to recall the crank decoder updates some variables like a RPM variable and a timer that's used to create crank ticks based on crank angle. You could probably write a different decoder that get's the data from the chip and updates these variables. If you study the rusEFI code you'll probably find it's not as scary as you might thing. However keep in mind you are the only one with the hardware and the only one who will have the ability to decode such a system. I can offer some help with the hardware stuff, but I'm weak when it come to code.
Nothing you said says it can't be done.

The AS5047D can handle up to well over 10K RPM, by the way.

My idea doesn't rely on IIC/I2C or SPI for engine operation, just getting the crank position on starting up. Everything else is interrupt driven like the typical toothed wheel with Hall effect sensors.

Thank you for doing your due diligence and researching what I'm talking about. :roll:

Enough said.
You can lead the horticulture but you can't make them think.
User avatar
kb1gtt
contributor
contributor
Posts: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

Re: VW 1980 aircooled Vanagon

Post by kb1gtt »

In another thread camperbonde noted he was hoping his distributor would work. I figured I'd inquire if there is a schematic or something that might help us offer some insight into the existing setup. Feel free to use circuits or such that aren't rusEFI. The group we have here is more embedded enthusiast's than pushing something specific. Perhaps that other thread was reference to the use of an absolute analog sensor, perhaps it reference to just getting it up and running with some other sensing circuit. There certainly is allot of stuff like getting the fuel system working, and getting it sparking that's a significant obstacle. I would suggest starting with a schematic. Even if it's a Pizza box, or coffee stained napkin, a schematic goes a long way in helping with the plan.
Welcome to the friendlier side of internet crazy :)
User avatar
camperbonde
Posts: 10
Joined: Tue Nov 17, 2015 7:50 am
Location: Sweden

Re: VW 1980 aircooled Vanagon

Post by camperbonde »

Thanks guys for the input!
I'm checking if I can order -UH or higher temperature radially magnetized magnets 10mm dia 6 mm thick for my project.
They will be cylinders as a central hole will reduce the field strenght.
I will be implementing some kind of toothed wheel signals as outputs as well as ignition control for my c.o.p. setup.
For the vacuum advance I'll be using 2 absolute pressure sensors then I'll also get altitude information.
I want to run it with the original bosch injection system before I tear that down.
I don't see the delays as a problem. I do get the angle at a specific time so using an adjusted lookup table or two with wheel output is simple.

The rusEFI could query my processor at startup for the engine position.

The reason I asked is that I'm slightly annoyed with my modern cars: chug chug chug chuwroooom... (Toyota vvti petrol, Hyundai diesel)
when all my old Saab's where like chuwrooom. (99 carb 99 mech.inj. 900 elec.inj.)
I still sometimes make the misstake of engaging the starter for a too short time.
(Even my Massey Fergusson 35 mech. inj. diesel from 1958 starts immidiately when warm. Not so for the 1992 Valmet 455)
Last edited by camperbonde on Thu Nov 19, 2015 12:15 pm, edited 1 time in total.
"Nihil humani a me alienum esse" T. Brahe
User avatar
camperbonde
Posts: 10
Joined: Tue Nov 17, 2015 7:50 am
Location: Sweden

Re: VW 1980 aircooled Vanagon

Post by camperbonde »

I want to run the rusEFI in my car but it needs some signals that are not there the engine is too old for that.
So first I'll have to do something about that, just to clarify.
pizza box schematic? I think I can do better.... but I kind of like the idea!
quick and dirty
quick and dirty
pizza.JPG (74.63 KiB) Viewed 18796 times
Of course the coils can be moved over to the rusEFI as well when I change injectors.
But to debug the wheel software I have to have a running system to hook up my sampling oscilloscope on.
Basically it's just a simple schematic for an electronic ignition with coils on the plugs.
"Nihil humani a me alienum esse" T. Brahe
Rhinoman
contributor
contributor
Posts: 256
Joined: Thu Sep 24, 2015 2:14 pm
Location: Wiltshire, UK

Re: VW 1980 aircooled Vanagon

Post by Rhinoman »

It would appear to emulate a resolver, I've used a few of those in the past on stabilised platforms for radar and gunfire control. The output from the resolvers was a much higher voltage though so the signal-noise ratio was quite good, using one resolver at motor speed and another at 4x motor speed we could get 20-bit resolution using tow 16-bit resolver-digital converters. You will need to sample sin and cos simultaneously, about 10 years ago I looked into decoding the signals digitally but it wasn't possible to get the accuracy, these days if you're using a Freescale chip then you can get a TPU function.
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: VW 1980 aircooled Vanagon

Post by AndreyB »

Rhinoman wrote:gunfire control
now we are talking :)

I think some of the older designs were starting faster because their trigger shape was a direct match of cranking mode ignition/injection, for example http://rusefi.com/wiki/index.php?title=Manual:Software:Trigger#Mazda_Miata_NA

Newer trigger wheels are moving towards higher number of smaller teeth so they need to sync before firing up anything. Please note that these are all just my wild guesses.
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
kb1gtt
contributor
contributor
Posts: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

Re: VW 1980 aircooled Vanagon

Post by kb1gtt »

Also worth keeping in mind, the metal and such around the magnet will also effect the flux. It can cause an increased concentration. If you know your mounting method, it's probably worth modeling it to get an estimate. Or at least get a magnet that has options with increased or decreased flux capabilities.

Do you think you can get all the components into the distributor?
Welcome to the friendlier side of internet crazy :)
User avatar
camperbonde
Posts: 10
Joined: Tue Nov 17, 2015 7:50 am
Location: Sweden

Re: VW 1980 aircooled Vanagon

Post by camperbonde »

Well the only components that also have to be in the distributor are a soic8 and a capacitor and some kind of pcb.
To get the right flux it's probably easiest to adjust the sensor's distance from the magnet.
I've done some rtfm and the stm32 chips are not as savy as I originally thought waitstates are inserted when you run above 16 MHz.
(You have to run the code in ram to get full speed.)
The same as a ATMEGA128 runs at (I think it was marketed as a processor for making an ecu but that was way back).
The analog inputs are rather simple no diff. inputs just single 0-Vsupply.
frontend.JPG
frontend.JPG (71.49 KiB) Viewed 18761 times
GW associates have magnets and chips about 10$ a set m.q. 10.
Samarium Cobalt 350 degree C working temp very good, Neodymium might be more risky at higher temps.
I have to consider the very high temps an aircooled engine can reach probably why the bosch ecu is placed where it is.
"Nihil humani a me alienum esse" T. Brahe
User avatar
camperbonde
Posts: 10
Joined: Tue Nov 17, 2015 7:50 am
Location: Sweden

Re: VW 1980 aircooled Vanagon

Post by camperbonde »

I've been writing the assembly code for a stm32f103xxx and need some hint on what kind of wheel's I shold simulate.
I think I'm in love there's soo much you can do with a few instructions in an arm processor...

Just do some simple sketch!
"Nihil humani a me alienum esse" T. Brahe
User avatar
kb1gtt
contributor
contributor
Posts: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

Re: VW 1980 aircooled Vanagon

Post by kb1gtt »

Why not do a DDS kind of theory, where you simply pump 1's and 0's out a pin. Then you can draw what ever wheel pattern you have in memory and pump it out a pin every blah seconds. Faster RPM means you simply decrease the blah seconds tick time. Can you get 7200 bits for .1 degree of resolution? I guess it would really be 14400 for cam and crank, but typically you have less teeth for the cam.
Welcome to the friendlier side of internet crazy :)
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: VW 1980 aircooled Vanagon

Post by AndreyB »

camperbonde wrote:need some hint on what kind of wheel's I shold simulate.
here are the ones we have built-in already: http://rusefi.com/wiki/index.php?title=Manual:Software:Trigger
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
Post Reply