Model Engine Ignitions

Home Model Engine Machinist Forum

Help Support Home Model Engine Machinist Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.
Well intended Ray but if memory serves me correct, others have gone down this path where input is rampant and every second one wants something different. Result is it never gets completed.
 
Hi Ray
I would prefer Option 2.Checking All the boxes by dragging the cursor over them and change them all with one click.
In real life one will Not change These numbers too often. So it should be done quick and easy.
Good work! Keep on.
 
Well intended Ray but if memory serves me correct, others have gone down this path where input is rampant and every second one wants something different. Result is it never gets completed.
I hear what your saying. I remember 2012 and all the different ideas but, I did not start that project. I also remember what Grompy said so, I will not let that happen here. I have learned from other projects I have done that sometimes you have to force people to accept and learn to use what they have been given. I learned there is always a time when a projects mandate has to be enforced and not accept more changes and have them sign off on it otherwise, your right it never gets completed.

There is another problem on the horizon and that has to deal with the shortage of the Atmega328P mcu. Because the cheap version won't be available for a year I will be asking for feedback on using an alternative mcu. Which one most people will feel comfortable using. I'm pretty sure I will use something like the ESP32 or RP2040 that is compatible with the Arduino IDE for programming. They are cheap, powerful, and available ......... overkill for this project.

Cheers
Ray
 
Hi Ray
I would prefer Option 2.Checking All the boxes by dragging the cursor over them and change them all with one click.
In real life one will Not change These numbers too often. So it should be done quick and easy.
Good work! Keep on.
Thanks.
I have some corrections to do like remove the pre selected cells. I also think I'll do something like Steve asked for by adding a textbox that shows the value one wants to place in the selected cells to remove any confusion and makes it easier to read. Also the "timing.csv" file will have some preloaded values to populate the cells.

How this works, is that when one selects save, it's the "timing.csv" file that gets updated. It is also the file that gets uploaded to the Nano mcu's EEPROM for timing advance.

Cheers
Ray
 
There is an old saying in computer programming "anything Microsoft makes, someone else also makes and makes it better". Now I use Microsoft's Visual Studio to write my programs. Why? well for 1 it's free and 2 that's what most others are using for general purpose programs and more. I started off using C# but, I couldn't get it to do what I wanted so, I switched to VB.NET. But that was so flakey that it was adding code that was wrong, losing my code, and becoming too difficult to use so, I switched back to C# and upgraded to Visual Studio 2022. VS 2022 works better in some ways but MS took out some features and added some. But in Microsoft's infinite wisdom and habit they do a real ****** job at documenting their stuff and a lot of stuff is hidden. Which means I have to search the internet for the info a lot. I like C# because it is somewhere between Visual Basic and C++ so once you get use to the syntax it's not too bad and Ii have had good success with it. But, my god has the number of features increased and it's easy to get lost.

Anyway, I have decided to go with option 2 and added a value textbox. The value textbox is only for visual reference. You can't enter in a value into it. I did this to save myself some coding for correct numbers being entered.

However:
One can chose individual cells and enter a value in them and/or,
One can hold down the control key and select different cells you want to change the value of using the Up/Down value changer and/or,
One can click on the blank box with the right arrow before the first row value and select the whole row, also using the Up/Down value changer and/or,
One can select a range of cells by holding down the left mouse button and dragging it across the cells you want or,
If your not happy with the selected cells you can click on the clear button to deselect All the cells and zero '0' their values.

After this you click on the "Apply" button to set the values. Once your happy with the values you click on the save button, to save the values to the "timing.csv" file for uploading to the mcu's EEPROM.

Setting_Timing.png


There are 3 other forms; 1 for setting the Hall-Effects' settings, 1 for setting up the USB ports settings, and 1 for options which, I'm still thinking about.

Hall_Set.jpg


USB_Set.jpg


For the options I was thinking about things like timing retard for starting and/or a rev limiter. Any ideas, anyone ????????

Cheers
Ray
 
I have decided to combine the Hall_Effect setting, Dwell, Rev Limiter, and Starting retard all on 1 page for simplicity sake.

Trigger Dwell Options.png


I also wanted to show people what the difference in coding between typing in a number and using the number up/down buttons. Because I need to check and make sure that someone has actually typed in a number there are multiple steps to see if it is a number. I will still have to use the first batch of code for the "Timing Retard" (Rev-Limiter) and the "Idle RPM" text boxes.

Code for checking if a text value is a number:

private void txtBoxHall_Leave(object sender, EventArgs e)
{
string numString = txtBoxHall.Text;
int number1 = 0;
int valueT;

bool canConvert = int.TryParse(numString, out number1);
if (canConvert == true)
{
valueT = Convert.ToInt32(numString);
if (valueT < 91)
{
Console.WriteLine("number1 now = {0}", numString);
}
else
{
txtBoxHall.Text = "0";
txtBoxHall.Focus();
MessageBox.Show("Number must be less than 91",
"Error", MessageBoxButtons.OK);
}

}
else
{
Console.WriteLine("numString is not a valid int");
txtBoxHall.Text = "0";
txtBoxHall.Focus();
MessageBox.Show("Must enter a whole number",
"Error", MessageBoxButtons.OK);
}
}

private void btnSave_Click(object sender, EventArgs e)
{
btnUpload.Enabled = true;

}

private void txtBoxHall_KeyDown(object sender, EventArgs e)
{
//txtBoxHall_Leave();
TextBox tb = new TextBox();
tb.KeyDown += new KeyEventHandler(tb_KeyDown);

}

private void tb_KeyDown(object sender, KeyEventArgs e)
{
//txtBoxHall_Leave();
string numString = txtBoxHall.Text;
if (e.KeyCode == Keys.Enter)
{
//enter key is down
Console.WriteLine("number1 now = {0}", numString);
txtBoxDwell.Focus();
}
}

Code if I use number up/down buttons:

private void numUpDownHall1_ValueChanged(object sender, EventArgs e)
{
int X;
X = (int)(numUpDownHall1.Value + numUpDown10Hall.Value);
txtBoxHall.Text = Convert.ToString(X);
}

private void numUpDown10Hall_ValueChanged(object sender, EventArgs e)
{
int X;
X = (int)(numUpDownHall1.Value + numUpDown10Hall.Value);
txtBoxHall.Text = Convert.ToString(X);
}

They both do the same thing, 50+ lines of code or just 12.
Of course there is still lots of coding to do and cleaning up, and maybe make it look pretty.

Cheers
Ray
 
I did a search for Free gauges that work with C# and serial data and came up with the below gauges. The website shows and says that there is a dial/needle face but it is actually only in the paid version. The gauges also include a demo mode which is cool. So what you see below is what I'm using for now.

Gauges.jpg


Cheers
Ray
 
Ray, if you run into any trouble getting the Nano to converse with the computer, and you are using the Arduino IDE, be aware that there are two different choices for the Nano; one is for the "old bootloader." I had to use that one for the Nanos that I have.
 
Ray, if you run into any trouble getting the Nano to converse with the computer, and you are using the Arduino IDE, be aware that there are two different choices for the Nano; one is for the "old bootloader." I had to use that one for the Nanos that I have.
Yah, all of mine except 1 are the same as your's, old bootloader.
The problem I'm having is that the serial com sends all characters as 8 bit characters and has to be converted into uint8_t (unsigned 8 bit integers) on the Nano side. Characters on the Nano side are only 8 bit characters, the Char is stored as a byte (8 bit) and indexing is by Byte so I can only receive up to 255 characters, when cleaned that makes it to 84.5 values stored. As far as converting them into uint8_t I'm using the 'C' atoi to do the conversion "timing_array(i) = atoi(strtokIndx);" This is the string of characters I'm sending but, in unicode (ASCII):

<,t,0,0,0,0,0,10,10,10,10,10,10,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,40,40,40,40,40,40,40,40,40,40,40,40,40,40,>

And this is the receive function:

Code:
void Checkserial() //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++serialEvent
  {
    static boolean recvInProgress = false;
    static byte ndx = 0;
    char startMarker = '<';
    char endMarker = '>';
    char rc;

// While the serial port is available and no work is being done
    while (Serial.available() > 0 && newData == false) //
    {
// Read the serial buffer
        rc = Serial.read();
        if (recvInProgress == true)
        {
// Not at the end of the message
            if (rc != endMarker)
            {
// Store characters in the array
                receivedChars[ndx] = rc;
                ndx++;
                if (ndx >= numChars)
                {
                    ndx = numChars - 1;
                }
            }
            else
            {
                receivedChars[ndx] = '\0'; // terminate the string
                recvInProgress = false;
                ndx = 0;
                newData = true;
            }
        }
        else if (rc == startMarker)
        {
            recvInProgress = true;
        }
    }
// this temporary copy is necessary to protect the original data
// because strtok() replaces the commas with \0   
    if (newData == true)
    {
        strcpy(tempChars, receivedChars);
        parseData();
        newData = false;
    }
  }

The tempChars and receivedChars are also indexed by Byte. I've tried everything I can think of except, sending 2 strings and joining them into an array and save that to the EEPROM. There are 2 other strings I need to send one is the settings and the other is the engine temperature compensation. Both of those are much shorter and won't be a problem.
So if you or anyone else has an idea, please let me know. In the meantime I'll try sending 2 strings.

Cheers
Ray
 
Last edited:
So I split the 100 timing cells into 2 and that is now working for uploading to the Nano. Sending 2 back-to-back strings of 50 cells. I'll have to remember this if I decrease the steps or increase the RPM range. I have found that I'll need to optimize the code for the Nano, I'm slowly running out of memory:
"Global variables use 1315 bytes (64%) of dynamic memory, leaving 733 bytes for local variables. Maximum is 2048 bytes."
I'll also optimize the PC program which, is just good coding. It mostly involves cleaning up unused variables or reusing some after zeroing them. So I now have 100 EEPROM locations holding my timing lookup table which gives me advance readings every 100 RPM to 10,000 RPM leaving me 924 locations for other stuff. The settings string only has 6 variables and the engine temperature compensation has 5. Not sure if I'm going to use celsius or fahrenheit or a choice of which.

I was thinking of using 100, 120, 140, 160, and 180 degrees 'F' or 40, 50, 60, 70, and 80 degrees 'C' for the lookup points, any ideas/thoughts?

I'm only going to send back to the computer 3 readings; RPM, timing advance, and engine temperature, these will get updated between the interrupts.

Also I won't be using a MAP sensor on this version, just a mechanical advance replacement on this version, so no maxing out the engine load.

Cheers
Ray
 
Below is the attached PDF "Help" file for the PC program.
I'm looking for feedback from anyone who wishes to express their ideas, thoughts, and questions on it, thanks.

Thanks
Ray
 

Attachments

  • Help.pdf
    511.7 KB
Just an update;
Well I believe I have both the PC & Arduino code Ready for testing. I'm sure that like any software I either forgot something or I didn't write something correctly and will need to be corrected. Hopefully it will just be minor things. The 4 stroke engine using wasted spark still needs to be refreshed but, I do have an old chainsaw 28cc that uses a really bad Walbro ignition and will not run so it's for testing. A 2 stroke is better than nothing right. It may or maynot hit the high RPM I'd like but, if it blows up I'm not out anything.

So what remains?
Just a bunch of clean up stuff but, that can take time, sometimes more than one wants or needs, we'll see how that goes. I promise better videos. Need to make and solder up a proper proto board. Install the PC program to my laptop which, has none of the PC code or it's dependencies on it, so it will be a clean install. I like to do this because it's the only way I can tell if I compiled the code correctly for someone that does not have all the dependencies on their computer. All programs designed for Windows/Mac/Linux need dependant programs to work correctly and I have to make sure they get installed correctly with the main program. I also need to order some small cylindrical magnets and make an aluminum trigger wheel. For load/dyno I'll probably use an old 12 volt alternator and have it charge the battery at the same time. This also means I can use the clutch on the saw. As far as what the ignition is doing I have setup serial monitor in Arduino IDE, Gauges in the PC software, a timing light, and some testing instruments.

I have used up 52% of the available code memory and could use even more but, the more I use the slower or less time the mcu has to respond. Besides I think there is more than what most people need but, less than I would like. Afterall I do plan on using this on my 7.5 litre V8 racing engine, 6,500 RPM limit. Anyway this is what the LCD shows for reporting right now. The minus -127.00 Celsius means there is a connection problem with the temperature probe, I have it disconnected right now to show this. It reports back either C or F, your choice.

LCD1.jpg


Cheers
Ray
 

Latest posts

Back
Top