Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I added way to output a MAP sensor signal for those working on using the MAP sensor for a CAM sensor #81

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ node_modules/
.DS_Store
UI/dist/
UI/yarn*


7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ Simply open the `ardustim` sub-folder in PlatformIO or the Arduino IDE and it sh

Intended hardware platform is the Arduino Nano or Uno.

## Map sensor Configuration
The wheel defination is diffrent in the a 10 or over is a tooth on the flywheel. 1x = a tooth
The right hand digit specifies the vaccum signal to output for a MAP sensor input. 0-9 for the output amount.
Since the Uno doesn't have a real DAC onboard it uses a simple R-2R network and can be made from a about 20 1K resistors on pins 2-7.
Is only a 6 bit DAC as the lower 2 pins of portd are used for the serial communications, plus you only have 10 settings of 0-9.


## Installing GUI from Source

### Pre-Requisites
Expand Down
2,740 changes: 1,384 additions & 1,356 deletions UI/firmwares/nano.hex

Large diffs are not rendered by default.

198 changes: 144 additions & 54 deletions UI/gear_generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,53 +74,98 @@ function draw_crank_gear(toothPattern, depth, radius, width, line, halfspeed) {
var teeth = toothPattern.length / 2;
if(halfspeed) { teeth = teeth / 2; }
var firstEnd

var analogMapMode = 0;
depth = (radius / 100) * depth;

for (var i = 0; i < toothPattern.length; i++)
{
if (toothPattern[i] >= 10) {analogMapMode = 1;}
}
c.beginPath();
//Draw an inner ring
c.arc(x, y, radius/5, 0, 2 * Math.PI);
c.moveTo(x+radius-depth, y); //Move to the starting point

for (var i = 0; i <= (teeth * 2)-1; i++)
if (analogMapMode == 0)
{

var start, end, newEnd, diff;
diff = ((((100 - width) / 100) / 2) * arcToRad(teeth));
newEnd = lastEnd + arcToRad(teeth);

start = lastEnd + diff;
end = newEnd - diff;

/*
* Values to use within a wheel definition.
* 0 means no tooth on any wheel definition
* 1 means crank tooth
* 2 means cam1 tooth
* 4 means cam2 tooth
*
* combinations of numbers mean all of the related teeth are present,
* eg 3 means crank and cam1, 5 means crank and cam2, 6 means cam1 and cam2, 7 means crank, cam1 and cam2
*/
if (toothPattern[i] == 1 || toothPattern[i] == 3 || toothPattern[i] == 5 || toothPattern[i] == 7)
for (var i = 0; i <= (teeth * 2)-1; i++)
{
c.arc(x, y, radius, start, end, false);
} else

var start, end, newEnd, diff;
diff = ((((100 - width) / 100) / 2) * arcToRad(teeth));
newEnd = lastEnd + arcToRad(teeth);

start = lastEnd + diff;
end = newEnd - diff;

/*
* Values to use within a wheel definition.
* 0 means no tooth on any wheel definition
* 1 means crank tooth
* 2 means cam1 tooth
* 4 means cam2 tooth
*
* combinations of numbers mean all of the related teeth are present,
* eg 3 means crank and cam1, 5 means crank and cam2, 6 means cam1 and cam2, 7 means crank, cam1 and cam2
*/
if (toothPattern[i] == 1 || toothPattern[i] == 3 || toothPattern[i] == 5 || toothPattern[i] == 7 )
{
c.arc(x, y, radius, start, end, false);
} else
{
c.arc(x, y, (radius - depth), start, end, false);
}
lastEnd = newEnd;
}
} else
{
for (var i = 0; i <= (teeth * 2)-1; i++)
{
c.arc(x, y, (radius - depth), start, end, false);

var start, end, newEnd, diff;
diff = ((((100 - width) / 100) / 2) * arcToRad(teeth));
newEnd = lastEnd + arcToRad(teeth);

start = lastEnd + diff;
end = newEnd - diff;

/*
* Values to use within a wheel definition.
* 0 means no tooth on any wheel definition
* 1 means crank tooth
* 2 means cam1 tooth
* 4 means cam2 tooth
*
* combinations of numbers mean all of the related teeth are present,
* eg 3 means crank and cam1, 5 means crank and cam2, 6 means cam1 and cam2, 7 means crank, cam1 and cam2
*/
dataNow = (toothPattern[i]);
remainder = 0;
while (dataNow >= 10)
{
dataNow -= 10;
remainder ++;
}
if (remainder == 1 || remainder == 3 || remainder == 5 || remainder == 7 )
{
c.arc(x, y, radius, start, end, false);
} else
{
c.arc(x, y, (radius - depth), start, end, false);
}
lastEnd = newEnd;
}
lastEnd = newEnd;
}
//Draw the final connecting line
//c.lineTo(x+radius, y);

c.strokeStyle = '#fefefe';
c.strokeStyle = '#fefefe';
c.fillStyle = "rgba( 51,141,198, 0.8 )";
c.fill();
c.lineWidth = line;
c.stroke();
}


function draw_cam_gear(toothPattern, depth, radius, width, line) {
var canvas = document.getElementById('cam');
var c = canvas.getContext('2d');
Expand All @@ -130,44 +175,89 @@ function draw_cam_gear(toothPattern, depth, radius, width, line) {
var x = canvas.width / 2;
var y = canvas.height / 2
var lastEnd = 0;
if(analogMapMode) { teeth = teeth / 2; }
var teeth = toothPattern.length / 2;

var analogMapMode = 0;
depth = (radius / 100) * depth;

for (var i = 0; i < toothPattern.length; i++)
{
if (toothPattern[i] >= 10) {analogMapMode = 1;}
}
if(analogMapMode) { teeth = teeth / 2; }
c.beginPath();
//Draw an inner ring
c.arc(x, y, radius/5, 0, 2 * Math.PI);
c.moveTo(x+radius-depth, y); //Move to the starting point

for (var i = 0; i <= (teeth * 2)-1; i++)
{

var start, end, newEnd, diff;
diff = ((((100 - width) / 100) / 2) * arcToRad(teeth));
newEnd = lastEnd + arcToRad(teeth);

start = lastEnd + diff;
end = newEnd - diff;

/*
* Values to use within a wheel definition.
* 0 means no tooth on any wheel definition
* 1 means crank tooth
* 2 means cam1 tooth
* 4 means cam2 tooth
*
* combinations of numbers mean all of the related teeth are present,
* eg 3 means crank and cam1, 5 means crank and cam2, 6 means cam1 and cam2, 7 means crank, cam1 and cam2
*/
if (toothPattern[i] == 2 || toothPattern[i] == 3 || toothPattern[i] == 6 || toothPattern[i] == 7)
{
c.arc(x, y, radius, start, end, false);
} else
if (analogMapMode == 0)
{
for (var i = 0; i <= (teeth * 2)-1; i++)
{
c.arc(x, y, (radius - depth), start, end, false);

var start, end, newEnd, diff;
diff = ((((100 - width) / 100) / 2) * arcToRad(teeth));
newEnd = lastEnd + arcToRad(teeth);
start = lastEnd + diff;
end = newEnd - diff;
/*
* Values to use within a wheel definition.
* 0 means no tooth on any wheel definition
* 1 means crank tooth
* 2 means cam1 tooth
* 4 means cam2 tooth
*
* combinations of numbers mean all of the related teeth are present,
* eg 3 means crank and cam1, 5 means crank and cam2, 6 means cam1 and cam2, 7 means crank, cam1 and cam2
*/

if (toothPattern[i] == 2 || toothPattern[i] == 3 || toothPattern[i] == 6 || toothPattern[i] == 7)
{
c.arc(x, y, radius, start, end, false);
} else
{
c.arc(x, y, (radius - depth), start, end, false);
}
lastEnd = newEnd;
}
} else /* CAM GEAR for MAP simulation mode */
{
for (var i = 0; i <= (teeth * 2)-1; i++)
{

var start, end, newEnd, diff;
diff = ((((100 - width) / 100) / 2) * arcToRad(teeth));
newEnd = lastEnd + arcToRad(teeth);
start = lastEnd + diff;
end = newEnd - diff;
/*
* Values to use within a wheel definition.
* 0 means no tooth on any wheel definition
* 1 means crank tooth
* 2 means cam1 tooth
* 4 means cam2 tooth
*
* combinations of numbers mean all of the related teeth are present,
* eg 3 means crank and cam1, 5 means crank and cam2, 6 means cam1 and cam2, 7 means crank, cam1 and cam2
*/
dataNow = (toothPattern[i]);
remainder = 0;
while (dataNow >= 10)
{
dataNow -= 10;
remainder ++;
}
if (remainder == 2 || remainder == 3 || remainder == 6 || remainder == 7)
{
c.arc(x, y, radius, start, end, false);
} else
{
c.arc(x, y, (radius - depth), start, end, false);
}
lastEnd = newEnd;
}
lastEnd = newEnd;
}

//Draw the final connecting line
//c.lineTo(x+radius, y);

Expand Down
Loading