Originally posted by ivconic
View Post
You can nick a "tic or few" more if you control the whole port instead picking it's pins separately.
Even that it's not the method which will provide you accurate timings... unfortunately.
What you are planning with this? Are you planning further improving... let's say adding a LCD and digital audio output?
Maybe soft buttons and more "jingle&bells"?
Each functionality you add later; will affect your present timings.
Without use of interrupts there is not much that can be done on this subject.
Problem is if you pick a timer for such task; you'll have to trim it and any customizing will affect some of the functions which are dependable on that timer.
I was carefully followed Joop's attempt on "PI ported to Arduino" and he did very basic but neat and precise job there.
Joop realized that you can't do much more of the things you probably wanted; if you stay within Arduino IDE limits.
Unfortunately it is true.
Using his approach i made small step forward by implementing I2C LCD and displaying (by now) only one variable on it.
I can share it here just as an example.
I took Barracuda and just pulled out CD40106 from it. Than attached Arduino on it's place...
[ATTACH]38775[/ATTACH]
Even that it's not the method which will provide you accurate timings... unfortunately.
What you are planning with this? Are you planning further improving... let's say adding a LCD and digital audio output?
Maybe soft buttons and more "jingle&bells"?
Each functionality you add later; will affect your present timings.
Without use of interrupts there is not much that can be done on this subject.
Problem is if you pick a timer for such task; you'll have to trim it and any customizing will affect some of the functions which are dependable on that timer.
I was carefully followed Joop's attempt on "PI ported to Arduino" and he did very basic but neat and precise job there.
Joop realized that you can't do much more of the things you probably wanted; if you stay within Arduino IDE limits.
Unfortunately it is true.
Using his approach i made small step forward by implementing I2C LCD and displaying (by now) only one variable on it.
I can share it here just as an example.
I took Barracuda and just pulled out CD40106 from it. Than attached Arduino on it's place...

[ATTACH]38775[/ATTACH]
Code:
#include <Wire.h> #include <LiquidCrystal_I2C.h> #include <LCDBitmap.h> LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); LCDBitmap bitmap(&lcd, 12, 0); #define DIGITAL_OUT PORTB #define TX_PIN_A 5 // 13 #define SAMPLE_PIN_B 4 // 12 #define SAMPLE_PIN_C 3 // 11 unsigned int Sample1Delay = 65295; static int value; static int Mikrosekunde; void setup () { Generator (); InitTimer2 (); InitTimer1 (); TCNT2 = 200; Serial.begin(1200); lcd.begin(16,2); welcome(); } void VoidDelay (unsigned int n) { n += 12; TCNT1 = n; bitSet (TIFR1, TOV1); while (!(TIFR1 & (1<<TOV1))) {;} } void loop () { serial_radno1(); lcd_delay_ispis(); } void InitTimer1 (void) { TCCR1A = 0; TCCR1B = 0; bitClear (TIMSK1, TOIE1); TCNT1 = 0; TCCR1B = 0x01; } void InitTimer2 (void) { TCCR2A = 0; TCCR2B = 0; bitSet (TIMSK2, TOIE2); TCCR2B = 0x05; } void Generator (void) { DDRB = B00111111; } void ReadDelayPot (void) { value = analogRead(A3); Sample1Delay = 65535 - 16 - value; Mikrosekunde = (65535 -Sample1Delay)/16; } ISR (TIMER2_OVF_vect) { TCNT2 = 47; //******************************** MAIN PULSE - TX ****************************** DIGITAL_OUT |= (1<<TX_PIN_A); VoidDelay (63935); DIGITAL_OUT &= ~(1<<TX_PIN_A); //******************************** MAIN DELAY *********************************** VoidDelay (Sample1Delay); //****************************** MAIN DELAY PULSE ******************************* DIGITAL_OUT |= (1<<SAMPLE_PIN_B); VoidDelay (64850); DIGITAL_OUT &= ~(1<<SAMPLE_PIN_B); //******************************** EF DELAY ************************************* VoidDelay (65135); //****************************** EF DELAY PULSE ********************************* DIGITAL_OUT |= (1<<SAMPLE_PIN_C); VoidDelay( 64850); DIGITAL_OUT &= ~(1<<SAMPLE_PIN_C); //******************************** EF+TX DELAY ********************************** VoidDelay( 64850); ReadDelayPot(); } void welcome() { lcd.clear (); lcd.setCursor(2, 0); lcd.print("BARRACUDA"); bitmap.begin(); bitmap.home(); for (byte x=0; x<=4; x++) { bitmap.line(x, BITMAP_H-1, x+BITMAP_H-1, 0, ON, NO_UPDATE); bitmap.line(x, 0, x+BITMAP_H-1, BITMAP_H-1, ON, NO_UPDATE); } bitmap.update(); } void lcd_delay_ispis() { lcd.setCursor(0, 1); lcd.print("D="); lcd.print(Mikrosekunde); lcd.print("uS "); delay(50); } void serial_radno1() { Serial.print("Analogue Value= "); Serial.print(value); Serial.println(); Serial.print("Sample1Delay= "); Serial.print(Sample1Delay); Serial.println(); Serial.print("Mikrosekunde= "); Serial.print(Mikrosekunde); Serial.print("uS"); Serial.println(); }
Ivconic
Why did you add R35 100k ? thanks
Comment