SparkFun Forums 

Where electronics enthusiasts find answers.

General MicroView Support area - You have questions, find your answers here.

Moderators: marcus@geekammo, Help@GeekAmmo

By veckoff
#185804
Hi,
I make a litle program with the Timerone library (http://www.prometec.net/wp-content/uplo ... merOne.zip) but the Microview don't display nothing
I know there are some incompatibilities when interrupts are used, this will be a case?

#include <TimerOne.h>
#include <MicroView.h>
#define myDir 3 // Direction
#define myStep 4 // Step

int paso = LOW;
int m, mu=0,md=0;
int s, su=0,sd=0;
int l, lu=0,ld=0,lc=0;
volatile float angulo = 0;
volatile long tiempo = 0;

float A;
long N;

void setup() {

uView.begin();// begin of MicroView
uView.clear(ALL); // erase hardware memory inside the OLED controller
uView.display(); // display the content in the buffer memory, by default it is the MicroView logo
uView.clear(PAGE);
digitalWrite(myDir, 0 );

Timer1.initialize(67839);
Timer1.attachInterrupt(anticlockwise);
}

void anticlockwise() {
paso!=paso;
digitalWrite(myStep, paso );
angulo=angulo + 0.0002826633165;
tiempo=tiempo + 68;
}

void loop() {
noInterrupts();
N = tiempo;
A=angulo;
interrupts();

uView.setFontType(0);
uView.setCursor(0,0);
uView.print(A);
uView.setCursor(0,8);
uView.print(N);


}
By scotta
#185847
I added uView.display(); to the end of loop() but it still didn't display anything.

I experimented and found that it works if you remove
//digitalWrite(myStep, paso );
from the interrupt routine. I don't know why this causes a problem.
Code: Select all
#include <TimerOne.h>
#include <MicroView.h>
#define myDir 3 // Direction
#define myStep 4 // Step

int paso = LOW;
int m, mu=0,md=0;
int s, su=0,sd=0;
int l, lu=0,ld=0,lc=0;
volatile float angulo = 0;
volatile long tiempo = 0;

float A;
long N;

void setup() {

uView.begin();// begin of MicroView
uView.clear(ALL); // erase hardware memory inside the OLED controller
uView.display(); // display the content in the buffer memory, by default it is the MicroView logo
uView.clear(PAGE);
digitalWrite(myDir, 0 );

Timer1.initialize(67839);
Timer1.attachInterrupt(anticlockwise);
}

void anticlockwise() {
paso!=paso;
//digitalWrite(myStep, paso );  // <- this causes the problem ***
angulo=angulo + 0.0002826633165;
tiempo=tiempo + 68;
}

void loop() {
noInterrupts();
N = tiempo;
A=angulo;
interrupts();

uView.setFontType(0);
uView.setCursor(0,0);
uView.print(A);
uView.setCursor(0,8);
uView.print(N);
uView.display(); // <- added this ***
}
By scotta
#185850
I found the problem. It's not obvious.

You are using pin 4 for myStep. Pin 4 is used to enable the 3.3V regulator that powers the display. When your interrupt routine set pin 4 LOW it powered off the display. Even setting pin 4 to HIGH would not make anything appear on the display because it is not being initialised again.

You also have an error in your code to toggle paso.
paso!=paso;
should be
paso = !paso;

Here's a working version, using pin 5 for myStep instead of pin 4
Code: Select all
#include <TimerOne.h>
#include <MicroView.h>
#define myDir 3 // Direction
#define myStep 5 // Step <- changed from pin 4 to pin 5 ***

int paso = LOW;
int m, mu=0,md=0;
int s, su=0,sd=0;
int l, lu=0,ld=0,lc=0;
volatile float angulo = 0;
volatile long tiempo = 0;

float A;
long N;

void setup() {

  uView.begin();// begin of MicroView
  uView.clear(ALL); // erase hardware memory inside the OLED controller
  uView.display(); // display the content in the buffer memory, by default it is the MicroView logo
  uView.clear(PAGE);
  digitalWrite(myDir, 0 );

  Timer1.initialize(67839);
  Timer1.attachInterrupt(anticlockwise);
}

void anticlockwise() {
  //paso!=paso; // <- this is wrong ***
  paso = !paso; // <- changed to this ***
  digitalWrite(myStep, paso );
  angulo=angulo + 0.0002826633165;
  tiempo=tiempo + 68;
}

void loop() {
  noInterrupts();
  N = tiempo;
  A=angulo;
  interrupts();

  uView.setFontType(0);
  uView.setCursor(0,0);
  uView.print(A);
  uView.setCursor(0,8);
  uView.print(N);
  uView.display(); // <- added this ***

}
By scotta
#185852
One more thing.

You are missing pinMode() functions to set the pins to outputs.
Code: Select all
void setup() {

  uView.begin();// begin of MicroView
  uView.clear(ALL); // erase hardware memory inside the OLED controller
  uView.display(); // display the content in the buffer memory, by default it is the MicroView logo
  uView.clear(PAGE);
  pinMode(myDir, OUTPUT);  // <- added this ***
  pinMode(myStep, OUTPUT); // <- added this ***    
  digitalWrite(myDir, 0 );

  Timer1.initialize(67839);
  Timer1.attachInterrupt(anticlockwise);
}
By veckoff
#185860
Hi Scotta,
well, my sketch work fine now, thanks.
I have a last question, I've been looking for a good diagram for pinout of the Microview that compare with the pins of Arduino Uno.
Where can I find this?
It would be easier to make the necessary program changes to move programs from arduino Uno to Microview.

By
By scotta
#185866
I don't know of any direct comparisons between the MicroView and an Arduino Uno.

The pinout for the MicroView is can be found here:
http://learn.microview.io/Intro/general ... oview.html
and a schematic is here:
https://cdn.sparkfun.com/datasheets/Dev ... roView.pdf

A similar pinout for the Uno is here:
https://i2.wp.com/foros.giltesa.com/otr ... ut/uno.jpg
and a schematic is here:
https://www.arduino.cc/en/uploads/Main/ ... ematic.pdf

The pin numbers are the same for the MicroView and the Uno but the MicroView only has connections for I/O pins:
0 (RXD), 1 (TXD), 2, 3, 5, 6
A0, A1, A2, A3, A4 (SDA), A5 (SCL)

The other pins available on the MicroView are:
GND, VIN, 5V, RESET