Pages: 1 [2]   Go Down
Author Topic: Running the sample "BLINK" program @ 16 MHz  (Read 1594 times)
0 Members and 1 Guest are viewing this topic.
Indy
Offline Offline
Newbie
*
Karma: 0
Posts: 43
YEAR of the DRAGON
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If it were possible to code it in Arduino firmware I'd
Gladly give it a go. Machine Language might be too
much for the short term. I really need a working,
adjustable program for proof of concept. I'll try
G&C and see if I get any nibbles THANX ALL!
Logged

working on my honorary doctorate LOL

0
Offline Offline
Faraday Member
**
Karma: 24
Posts: 3486
20 LEDs are enough
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ultrashort pulses? Search for "direct port manipulation". This is not hard to pull off.
Logged

Check out my experiments http://blog.blinkenlight.net

Indy
Offline Offline
Newbie
*
Karma: 0
Posts: 43
YEAR of the DRAGON
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

U know, I should try and do it myself if you folks can help
me get started. I want a very simple program like BLINK in
Machine Language and have adjustable (through code changes)
on and off phases. That is all I need, just a simple code for
ON & OFF. Once I prove the concept I can then get elaborate
and get an ARM based system and program in my safeties &
adjustable outputs, preferably using GUI which is prolly like
developing "windows" from the ground up  smiley smiley smiley
Any idea where I should start??? Still a total noob/newb and
I work/drive over 12 hours a day which is the reason I am a
bit slow on the R&D phase. Which Machine Language would
I learn or is that a stupid Q (is it all the same w/hdwe. variants?)
So much to do with so little time

TIA Y'all!
undeRGRound
Logged

working on my honorary doctorate LOL

Indy
Offline Offline
Newbie
*
Karma: 0
Posts: 43
YEAR of the DRAGON
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

THX UDO!!! looking
Logged

working on my honorary doctorate LOL

SF Bay Area (USA)
Online Online
Tesla Member
***
Karma: 134
Posts: 6760
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you see this thread: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1230286016

How exactly timed does the "off" time have to be?

Code:
/*
  * pulse PORTB5 (LED) for n machine cycles (62.5ns each)
 * The off time is not particular controlled.
 */
void pulse(int n)
{
  uint8_t on, off;    //values for port reg with LED on and off

    cli();
  off = PORTB;
  on = off | (1<<PORTB5);
  switch(n) {
  case 1:
    asm volatile (
    " out %[port], %[on]\n"
      " out %[port], %[off]\n"
: //output specs (none)
:
    [port] "I" (_SFR_IO_ADDR(PORTB)),
    [on] "r" (on),
    [off] "r" (off));
    break;
  case 2:
    asm volatile (
    " out %[port], %[on]\n"
      " nop\n"
      " out %[port], %[off]\n"
: //output specs (none)
:
    [port] "I" (_SFR_IO_ADDR(PORTB)),
    [on] "r" (on),
    [off] "r" (off));
    break;
  case 3:
      asm volatile (
    " out %[port], %[on]\n"
      " nop\n nop\n"
      " out %[port], %[off]\n"
: //output specs (none)
:
    [port] "I" (_SFR_IO_ADDR(PORTB)),
    [on] "r" (on),
    [off] "r" (off));
    break;
  default:
    // other values are easier.
    // And left as an exercise for the reader.
    break;
  }
  sei();
}

void setup() {
}
void loop() {
  for (int i = 0; i < 100; i++) {
    pulse(i);
  }
}
Logged

Indy
Offline Offline
Newbie
*
Karma: 0
Posts: 43
YEAR of the DRAGON
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ultrashort pulses? Search for "direct port manipulation". This is not hard to pull off.

PS: I also need off phase to be 500 to 10,000 times or more longer.
Logged

working on my honorary doctorate LOL

Indy
Offline Offline
Newbie
*
Karma: 0
Posts: 43
YEAR of the DRAGON
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you see this thread: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1230286016

How exactly timed does the "off" time have to be?
   

Well for proof of concept total cycle time will likely fall around
1000 Hz (.001 sec) give or take. At this point adjusting the
Mark/Space timing will be needed, but if the concept is proven
I will be able to pour in some real money $
I will check these things THANK YOU ALL
Logged

working on my honorary doctorate LOL

Indy
Offline Offline
Newbie
*
Karma: 0
Posts: 43
YEAR of the DRAGON
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@westfw:
Need to get the OL off the computer, the code does not
display properly on the iPhone. Need iPad I guess smiley
Accuracy of OFF times is not at all critical, I take it
you are implying it will be in a multiple of 62.5 nSec
which is perfectly acceptable. The ON increment is small
enough that a multiple will work well. A few nSec one way
or the other prolly makes no difference at all at this point.
Off times will be huge in comparison to the On times.
Later I believe that true nanosecond control will pay dividends
but the basic design is likely to work with these specs. It will
SURELY yield some valuable data if not total proof of theory.
Logged

working on my honorary doctorate LOL

SF Bay Area (USA)
Online Online
Tesla Member
***
Karma: 134
Posts: 6760
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I take it you are implying it will be in a multiple of 62.5 nSec which is perfectly acceptable.
Yes, it will be a multiple of 62.5ns (everything will be!), but that isn't the point.
The point is that if you have a short-ish "on" pulse, you only have to generate "exact" code for the duration of that pulse.  If you need both the on and off times to be accurate (note that "accurate" is different than "short"), you pretty much have to control ALL of the code, which is MUCH harder.  Figure that an average Arduino program can output a nearly exact 62.5ns pulse every 10ms +/- 5 ms (which is a LOT of variation in the off time.)

You're not reinventing MPIR, are you?
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18806
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Seems the PWM is limited in speed and I need
to have the ability to set an output and a pause and repeat.


To be honest I don't understand this.
Your PWM output can be up to the clock speed.
Thus you can have one pulse every 62.5 nS.
That isn't "limited in speed".
Logged


Indy
Offline Offline
Newbie
*
Karma: 0
Posts: 43
YEAR of the DRAGON
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@ westfw:
That could be acceptable for proof of concept. Slow but OK.
65 to 200 Hz is relatively slow (I see 1000 Hz as my low end)
But materials questions arise @ 1kHz range anyway.
What is MPIR? Hope no one has done what I'm doing smiley


@ Nick Gammon:
I had read that using the native PWM was slowed by the coding
Or something, what I am trying to do is get a minimal ON pulse
and adjustable on/off phases. The intended device to be controlled
is not an LED, I just need the ^**above^^^ mentioned pulses and
a wide range of adjustability. For now let's just say all I need is to
Generate a 'Scope Trace which is mostly FLATLINE...
Logged

working on my honorary doctorate LOL

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18806
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@ Nick Gammon:
I had read that using the native PWM was slowed by the coding
Or something...

Oh aye.
Where did you read that?
Logged


Pages: 1 [2]   Go Up
Jump to: