Recent Posts

Pages: [1] 2 3 4 5 6 ... 10
1
Sebosfato / Re: Arduino Analog Instruments
« Last post by Hidden on Today at 05:26:13 »

i turned off serial port of the arduino

i tweeked a little to start at 10hz but this also reduced the max freq to 130khz because i had to use 3 delays to lower from 30 to 10 hz the steps also changed it could be improved using a float perhaps but is already good for what i need now that is just a clock output to mimic the rpm sensor.. this will trigger the other arduino injection system while i dont plug it to the car fox ex

i improved the rotary input pins so i can use a fix pack of wires  in right order

and reversed the action of the switch and added a range  so  it now dont really need the save function because it became very fast to find the desired frequency

the button basically set how fine is the adjust and at the same time as consequence limit the ranges making it easy to work without display

now it goes from

10-555hz
10-1.6khz
10-16khz
10-130kz

hope you enjoy

new code:

// -----
// InterruptRotator.ino - Example for the RotaryEncoder library.

// -----because of the limited range the lowest freq that can be generated with delayMicrosecond function is 30Hz but using normal delay it can be much lower perhaps 0,03hz

//the highest is 254khz

//freq adjust

//at 100hz  the smallest increase step is 0,02hz    //  dutycycle49,9%
//at 1khz   the smallest increase step is 2<>2hz   //  dutycycle  49,8%
//at 10khz the smallest increase step is 185<>200hz   //  dutycycle   48,6%
//at 100khz the smallest increase step is  17kz<>26kz    //  dutycycle 36,5%
//at 254khz the smallest decrease step is  86kz<     //  dutycycle 15,8%

//the frequency is stable with cristal precision! <1%

//i used This example that checks the state of the rotary encoder in the loop() function.
// The current position is printed on output when changed.

// Hardware setup:
// Attach a rotary encoder with output pins to A2 and A3.and switch to pin 3 to trigger interrupt1 added a small debounce capacitor from this pin to ground
// The common contact should be attached to ground.

#include <RotaryEncoder.h>

unsigned int range=1000;
int swt=3;
unsigned int pos = 0;
unsigned int microdelay=16300;

RotaryEncoder encoder(A3, A2);// Setup a RoraryEncoder for pins A2 and A3:

void setup()
{
DDRB |= 0B00100000; // activate pin13
cli();
TIMSK0 &= ~(1 << TOIE0);  // disable timer (no millis)
sei();

pinMode(swt, INPUT_PULLUP);
attachInterrupt(1,swtch,FALLING);  // pin3
//Serial.begin(57600);
//Serial.println("Arduino Frequency Generator with RotaryEncoder library.");
// You may have to modify the next 2 lines if using other pins than A2 and A3
PCICR |= (1 << PCIE1);    // This enables Pin Change Interrupt 1 that covers the Analog input pins or Port C.
PCMSK1 |= (1 << PCINT10) | (1 << PCINT11);  // This enables the interrupt for pin 2 and 3 of Port C.
}


// The Interrupt Service Routine for Pin Change Interrupt 1 but the pin 3 interrupt sill work
// This routine will only be called on any signal change on A2 and A3: exactly where we need to check.
ISR(PCINT1_vect) {
  encoder.tick(); // just call tick() to check the state.
}

void loop()
{
  unsigned int newPos = encoder.getPosition();
  if (pos != newPos) {
  // Serial.println(newPos);
   //Serial.println(microdelay);// Read the current position of the encoder and print out when changed.

 if ((newPos > pos)&& ((microdelay+range) <= 16300))  {
  microdelay= microdelay + range;
  }else if ((newPos<pos) && ((microdelay-range) >= 1)&& (microdelay-range)<=16300){
    microdelay= microdelay - range;
  }
     pos = newPos;
  }

microdelay= constrain((microdelay),1,16300);
PORTB |= 0B00100000;   //pin 13  on
   delayMicroseconds(microdelay);
    delayMicroseconds(microdelay);
     delayMicroseconds(microdelay);
PORTB &= 0B11011111;   //pin 13  off
   delayMicroseconds(microdelay);
    delayMicroseconds(microdelay); delayMicroseconds(microdelay);
    }
void swtch (){
if (digitalRead(swt)== LOW)range=range/10;
if (range <1) range=1000;
//Serial.println (range);
  }

2
Sebosfato / Re: Arduino Analog Instruments
« Last post by Hidden on Today at 03:55:30 »
just missing the save function to have the last frequency automatically recall

i dont think it will work on esp chips but probably will work on any arduino board

i´m using arduino nano 328/p processor to upload i have to select on arduino ide the nano board and set it as old boot loader since mine is a china one probably..

3
Sebosfato / Re: Arduino freq generator
« Last post by Hidden on Yesterday at 22:23:01 »
i was trying to make a frequency generator with arduino and a rotary encoder... was harder than i imagined...

but i´m using the encoder to count up or down the delay time the encoder got unresponsive at low frequencies so i had to take other way

i used a interrupt based library for the encoder so it connects to A2 and A3 analog inputs..

if it is going up it sums with the delay time according to a range determined by the encoder switch connected to D4 so if i press it it can sum or subtract 1 , 10 or 100 or  for each encoder count.. the value of the delay range within is btw 1us and 16300 (thats the upper limit lowest freq)

because of the limited range the lowest freq that can be generated with delayMicrosecond function is 30Hz but using normal delay it can be much lower perhaps 0,03hz

the highest is 254khz

freq adjust

at 100hz  the smallest increase step is 0,02hz    //  dutycycle49,9%
at 1khz   the smallest increase step is 2<>2hz   //  dutycycle  49,8%
at 10khz the smallest increase step is 185<>200hz   //  dutycycle   48,6%
at 100khz the smallest increase step is  17kz<>26kz    //  dutycycle 36,5%
at 254khz the smallest decrease step is  86kz<     //  dutycycle 15,8%

the frequency is stable with cristal precision! <1%

there is a lower frequency noise on the voltage level of the output pulses but it can be reduced adding more capacitors to the arduino voltage line i guess it could increase the frequency stability even further


the code:

// -----
// InterruptRotator.ino - Example for the RotaryEncoder library.
// This class is implemented for use with the Arduino environment.

// -----because of the limited range the lowest freq that can be generated with delayMicrosecond function is 30Hz but using normal delay it can be much lower perhaps 0,03hz

//the highest is 254khz

//freq adjust

//at 100hz  the smallest increase step is 0,02hz    //  dutycycle49,9%
//at 1khz   the smallest increase step is 2<>2hz   //  dutycycle  49,8%
//at 10khz the smallest increase step is 185<>200hz   //  dutycycle   48,6%
//at 100khz the smallest increase step is  17kz<>26kz    //  dutycycle 36,5%
//at 254khz the smallest decrease step is  86kz<     //  dutycycle 15,8%

//the frequency is stable with cristal precision! <1%

//i used This example that checks the state of the rotary encoder in the loop() function.
// The current position is printed on output when changed.

// Hardware setup:
// Attach a rotary encoder with output pins to A2 and A3.and switch to pin 3 to trigger interrupt1 added a small debounce capacitor from this pin to ground
// The common contact should be attached to ground.

#include <RotaryEncoder.h>

unsigned int range=100;
int swt=3;
unsigned int pos = 0;
unsigned int microdelay;

RotaryEncoder encoder(A2, A3);// Setup a RoraryEncoder for pins A2 and A3:

void setup()
{
DDRB |= 0B00100000; // activate pin13
cli();
TIMSK0 &= ~(1 << TOIE0);  // disable timer (no millis)
sei();

pinMode(swt, INPUT_PULLUP);
attachInterrupt(1,swtch,FALLING);  // pin3
Serial.begin(57600);
Serial.println("Arduino Frequency Generator with RotaryEncoder library.");
// You may have to modify the next 2 lines if using other pins than A2 and A3
PCICR |= (1 << PCIE1);    // This enables Pin Change Interrupt 1 that covers the Analog input pins or Port C.
PCMSK1 |= (1 << PCINT10) | (1 << PCINT11);  // This enables the interrupt for pin 2 and 3 of Port C.
}


// The Interrupt Service Routine for Pin Change Interrupt 1
// This routine will only be called on any signal change on A2 and A3: exactly where we need to check.
ISR(PCINT1_vect) {
  encoder.tick(); // just call tick() to check the state.
}

void loop()
{
  unsigned int newPos = encoder.getPosition();
  if (pos != newPos) {
  // Serial.println(newPos);
   Serial.println(microdelay);// Read the current position of the encoder and print out when changed.

 if ((newPos > pos)&& ((microdelay+range) <= 16300))  {
  microdelay= microdelay + range;
  }else if ((newPos<pos) && ((microdelay-range) >= 1)&& (microdelay-range)<=16300){
    microdelay= microdelay - range;
  }
     pos = newPos;
  }

microdelay= constrain((microdelay),1,16300);
PORTB |= 0B00100000;   //pin 13  on
   delayMicroseconds(microdelay);
PORTB &= 0B11011111;   //pin 13  off
   delayMicroseconds(microdelay);


       
  }
void swtch (){
 
    if (digitalRead(swt)== LOW)range=range*10;

 if (range > 100) range=1;
Serial.println (range);
  }

4
Sebosfato / Re: transporting ionized gas
« Last post by Hidden on August 19, 2018, 19:25:50 pm »
transporting ionized gas is the same as run with a bucket full of water in your hands.. you will get wet

the ionized gas will be attracted by any metal or even plastic by the electronic polarization, at plastics it will get stuck and only partially discharged but with metals it lose its charge...

so the strategy is to have a very well insulated tubing that brings all the ionized gas straight into the combustion chamber.. silicon tubing seems a good option since stand high temps

also the injector must have a high voltage isolation from the car parts

when you charge something with high voltage it will have the opposite charge of the voltage you charged it with but it can even create higher voltages if this charges are collected at a point..

i think the injector should be totally plastic solenoid.. for it to work,,  perhaps costume made


Interesting stuff
Never thought on that one..
5
Sebosfato / THE GMS IMPORTANCE
« Last post by Hidden on August 19, 2018, 19:13:32 pm »
I´m very happy with the development of the arduino GMS because i realized it is just the best way to prove the technology of the enhancement of the combustion process with good indication numbers etc.

It will be able to control the rpm of the engine by a feedback of the pressure and rpm read and the set acceleration rpm

the difference between the read rpm and the set rpm will determine if the circuit is accelerating or not and how much

this causes an increase in injection time that automatically adjust to bring the engine rpm close to the set rpm

this comparison between the rpm is not by phase difference , its a digital comparison between numbers so the frequency can work out of lock without problem and always bring the circuit to the correct direction rapidly as it can be calculated very very fast!

the measured rpm comes from the engine clock that is counted and so every 500ms it saves the number into a variable and the rpm is  subtraction the previous value from it  and mutiplied by 120 


i found that the arduino generate extremely stable frequency due to the cristal source.. but to achieve that and the full speed it require to turn of the timer that governs the millis and other funtions and directly manipulate the ports with bits
6
Sebosfato / Re: Retry N1001
« Last post by Hidden on August 19, 2018, 17:30:54 pm »
7
Sebosfato / Re: Arduino Analog Instruments
« Last post by Hidden on August 19, 2018, 16:43:12 pm »
8
Sebosfato / Re: Arduino Analog Instruments
« Last post by Hidden on August 19, 2018, 09:48:51 am »
the possible outputs with different smallest  configurations of delaymicroseconds are :

2Mhz 1:1
800,360khz   1:2
500Khz 2:2
333khz  3:2
250khz  3:3
200khz  4:3
166,744khz  4:4
142,922khz 5:4
125,058      5:5
111,162   5:6

at lower frequencies the precision distance between frequency decreases

the order of the factor dont change the time per se meaning that the on time and off time are exactly proportional

it seems the microseconds is the lowest division possible
9
Sebosfato / Re: Arduino Analog Instruments
« Last post by Hidden on August 19, 2018, 09:26:28 am »
with some the hint of the guy in the video on the first page for turning off the timer that creates those strange behavior and by manipulating the ports directly instead of the digitalwrite  i was able to generate a very extremely stable frequency nicely almost 50% square 500,230khz with arduino nano using 2useconds on and off (this delay should actually give 250khz but strangely gives 500) using 1usec on and 1 off gives 2Mhz but is not square anymore

this may be the scales it have of division inside the processor..

i imagine the processor has a 16Mhz cristal as a clock source so 2Mhz is 16/8 and 500 is 16/32

but i still didnt understood how does it relate with the time and frequency discrepancy

at lower frequency it seems to have lower discrepancy but although it generate many very precise frequencies it does not generate a continum analog like of course


here is the code to start playing with it :
ps i left the digitalwrite there for you to compare..



//int fakeclock = 13;

void setup() {
//
//pinMode(fakeclock, OUTPUT);
DDRB |= 0B00100000;
cli();
TIMSK0 &= ~(1 << TOIE0);
sei();
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:
//digitalWrite(fakeclock, HIGH);
PORTB |= 0B00100000;
delayMicroseconds(2);
PORTB &= 0B11011111;
//digitalWrite(fakeclock, LOW); 
delayMicroseconds(2);
}



10
Sebosfato / Re: Arduino Analog Instruments
« Last post by Hidden on August 19, 2018, 07:44:25 am »
i added a taskscheduler to have multiple loops for different functions other than the interrupt... one is just to print on the serial monitor every 3 seconds... what i noticed is that to print the info causes instability of the signal but also without printing there are other factors to get hid off

i used one of the outputs of the arduino as a clock generator to test the rpm meter and worked but there is still some instability

i added the limits of the rpm and injector timing respectively 0-7000rpm 0-5v ,  1ms and 10ms.

so the accelerator set the rpm and the arduino set the injectors parameters until it matches the rpm desired

anyone who wants to help finding problems and solutions for them i appreciate




unsigned long newtime;
unsigned long lasttime;

#include <TaskScheduler.h>

int clocksignal = 3; // //input interrupt 1 / pin 3
float injectiontime = 5; //ms  injection timming
int injector = 13;  // injector output
int rpmread = 0;
int accel = A0;   // analog/digital accelerator signal
int pressure = A1;
int rpmset = 0; // rpm determined by analog/digital accelerator
String state;
float timeincrement = 0.1;
float timedecrement = 0.1;
int mininjectiontime = 1;
float maxinjectiontime=10;
int maxrpmset=7000;
int clockcount=0;
int lastclockcount;
int fakerpm=20; // 10ms=6000rpm 20ms=3000 30ms= 2000 60= 1020rpm 75 =780 //fakesignal repetition
int fakeclock = 5; //pin5 output fakeclock   --- connect to pin 3 for simulating engines on .. controle its rpm at task t4


void t1Callback();
void t2Callback();
void t3Callback();
void t4Callback();
//Tasks
Task t1(300, TASK_FOREVER, &t1Callback);    //
Task t2(3000, TASK_FOREVER, &t2Callback);     //
Task t3(500, TASK_FOREVER, &t3Callback); //
Task t4(fakerpm, TASK_FOREVER, &t4Callback);     // 10ms=6000rpm 20ms=3000 30ms= 2000 60= 1020rpm 75 =780 //fakesignal repetition
Scheduler runner;


void INJECTION() {  //interrupt routine
 
 
   digitalWrite(injector, HIGH);
   delayMicroseconds(injectiontime*1000);
   digitalWrite(injector, LOW);
   clockcount++;
 // Serial.print("INJECTED FOR: ");Serial.print(injectiontime);Serial.println("injectiontime");
 

   //Serial.println(clockcount);Serial.println("");Serial.println("");
   //Serial.print(rpmread);
//Serial.println(" RPM Measured ");
}


void t1Callback() {
   
 
 rpmset=constrain((analogRead(accel)*6),0,maxrpmset);   // rpm determined by analog/digital accelerator

 if (rpmset > rpmread ) {
  state="Accelerating" ;  // injection time increase
  injectiontime=constrain((injectiontime+timeincrement),1,10);
  }
else {
  state="Deaccelerating"; // injection time reduce
  injectiontime=constrain((injectiontime-timedecrement),mininjectiontime,maxinjectiontime); 

}
 }

void t2Callback() {

Serial.print("Accelerator  ");
Serial.print(rpmset);
Serial.println(" RPM SET");
Serial.print("Injection Time ");
Serial.print(injectiontime);
//Serial.print(injectiontime);
Serial.println(" miliseconds");
Serial.print(rpmread);
Serial.println(" RPM Measured ");
Serial.println(state);
Serial.println(lastclockcount);

}
//____________________________________________________________________________________________________task3
void t3Callback() {
rpmread=(clockcount-lastclockcount)*60*2;
   lastclockcount=clockcount;
 }

//____________________________________________________________________________________________________task4

void t4Callback() {// fake signal

digitalWrite(fakeclock, HIGH);
delayMicroseconds(100);
digitalWrite(fakeclock, LOW); 
  }



void setup() {
  Serial.begin(9600);
  pinMode(clocksignal, INPUT_PULLUP);
  pinMode(injector, OUTPUT);
  pinMode(fakeclock, OUTPUT);

  attachInterrupt(1, INJECTION, FALLING);

 
  runner.init(); //"Initialized scheduler"
  runner.addTask(t1);
  runner.addTask(t2);
 runner.addTask(t3);
  runner.addTask(t4);
 t1.enable();   
 //t2.enable(); 
 t3.enable(); 
 t4.enable();

;}

void loop() {
runner.execute();
 
}


Pages: [1] 2 3 4 5 6 ... 10