95Views10Replies

Author Options:

Aruino question Answered

I have the arduino uno and i wsa wondering if there is a way i can get it to 3.26 mhz pulse? I don't care if it involves electrical parts.

Tags:arduino

Discussions

None
iceng

Best Answer 7 years ago

The Uno has a 16 Mhz clock, you should be able to program an output pin to
your desired frequency with software.

A

None
jbaker22iceng

Answer 7 years ago

i can only get 63.5 khz shuld i try to get the frequency faster another way besides using decimals of a millisecond?

None
icengjbaker22

Answer 7 years ago

I take it you don't do machine code.

None
icengjbaker22

Answer 7 years ago

This text box is not large enough to teach machine code.

Lets try another approach,  buy a 3.26 Mhz crystal on ebay or Dig-ikey
and a buffer driver.

None
jbaker22iceng

Answer 7 years ago

I modified a program and it has a flaw that if i make a decimal of a mirosec. it will pulse at 30hz. The greatest pulse is 99.3khz. This is when i tell it to delay for 1 mircosec. Can you explain why this doesn't make 1 mhz?

int outpin = 8;
void setup()
{
pinMode(8, OUTPUT);
}

void loop()
{
digitalWrite(8, HIGH);
delayMicroseconds(1);
digitalWrite(8, LOW);
delayMicroseconds(1);
}

None
icengjbaker22

Answer 7 years ago

Executing the C code instruction line takes more then a micro second.
Watch what happens when drop the delay instruction.

int outpin = 8;
void setup()
{
pinMode(8, OUTPUT);
}

void loop()
{
digitalWrite(8, HIGH);
digitalWrite(8, LOW);
}

In assembly code

LOOP:
     set p8
     nop
     nop  ' No Operation for a machine cycle
     nop
     clr p8
     nop
     jmp LOOP  ' jump is equal to two nop

None
jbaker22iceng

Answer 7 years ago

My arduino said there was a code problem, but where you trying to make a nanosecond pulse?

None
icengjbaker22

Answer 7 years ago

I was trying to show you that C-code takes many microseconds to execute and you don't need a delay.

Each C-code instruction takes many assembly code operations.
I hope you also learn about marking a Best answer.

None
jbaker22iceng

Answer 7 years ago

Thanks a whole lot for your help. I am still learning a lot from tutorials on arduinos, but you have helped me a lot too.