Coarse Bit Banged High Speed Outputs

Official FreeEMS vanilla firmware development, the heart and soul of the system!
Post Reply
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Coarse Bit Banged High Speed Outputs

Post by Fred »

For tacho drive and knock windowing we'll be providing the following fairly coarse signal possibility:

Twiddle a bit for each and every RPM input event that can be scheduled from.

Per output pin options for each input event will be:
  • Do nothing
  • Turn pin on
  • Turn pin off
  • Invert pin state
We'll support 4 or 8 outputs like this, 4 at first, 8 if there is demand. Each one will have:
  • Pointer to the control register for the port being used
  • Bit mask for pin
I'll configure this to strobe some of my dev pins, so expect some of those to flash on your setup if you have LEDs attached. In the long term the default will be OFF.

This will burn 256 bytes of linear flash (512 if we move to 8 outputs), which is nothing really, and provide some really powerful functionality, especially if you're running a high res wheel like 60-2.

This will need some config exclusion on the GPIO stuff too. IE, the port will need to be registered with the central pin registry.

For example, on a DSM or 4/1 CAS you could reasonably configure it to pulse 4 times per engine cycle, either longer on or longer off. Either possible config would work fine for a tacho, one will be better for knock.

Users with low res inputs and low cylinder/output counts could also use Sean's XG BB stuff for these functions and obtain higher resolution.

Fred.
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: Coarse Bit Banged High Speed Outputs

Post by Fred »

Code to be positioned after scheduling and possibly outside of sync space such that input noise shows up as noise in a tacho, or not, what about knock chips?

Code: Select all

if(arrayOfCoarseConfs[currentEvent]){
    int offset;
    for(offset=0;offset<numCoarseOuts;offset++){
        unsigned char behaviour = (arrayOfCoarseConfs[currentEvent] >> offset) & 0x03;
        if(behaviour){
            if(behaviour == 1){
                configuredPorts[offset] |= configuredMasks[offset];
            }else if(behaviour == 2){
                configuredPorts[offset] &= ~(configuredMasks[offset]); // syntax correct for 8/16 bits?
            }else if(behaviour == 3){
                configuredPorts[offset] ^= configuredMasks[offset];
            }
        }
    }
}
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: Coarse Bit Banged High Speed Outputs

Post by Fred »

numCoarseOuts should be configured to how ever many are being used so loop iterations is kept to a minimum. loop will only run if something is needed on this event anyway.

All array vars should be set to zero when not in use, along with the numCoarseOuts var set to zero such that time isn't wasted with two checks instead of one.

Perhaps add a config check to exclude the possibility of non zero array entries with zero numCoarseOuts or all same entries for numCoarseOuts not equal zero.
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: Coarse Bit Banged High Speed Outputs

Post by Fred »

This is finally in the code base! Time to move this thread out of hiding :-)

Code is 2 + months old and worked perfectly pretty much as-is.

http://issues.freeems.org/view.php?id=296

Fred.
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
Post Reply