Show Posts
|
|
Pages: 1 ... 3 4 [5] 6 7 ... 218
|
|
62
|
Using Arduino / Programming Questions / Re: Complier woes changing float to long
|
on: May 08, 2013, 07:27:56 am
|
Put your code with the #if stuff into another file (any .cpp in the same directory). The main sketch is transformed into a .cpp file by the IDE which then looks about this: #line 1 "sketch_may08a.ino"
#include "Arduino.h" void setup(); void loop(); long mytest(); float mytest(); #line 2 void setup() { // put your setup code here, to run once: }
void loop() { // put your main code here, to run repeatedly: }
#ifdef TESTING long mytest() { } #else float mytest() { } #endif
As you can see the IDE is providing the prototypes and don't care for the precompiler directives. It doesn't do that for the other files, just for the main sketch (*.ino).
|
|
|
|
|
63
|
Using Arduino / Programming Questions / Re: spi 9bit eeprom address can only see addr 0x00?
|
on: May 08, 2013, 07:18:53 am
|
same results. one thing, the chip speed is 3.3mhz, do i have that set correctly? Where is this comment coming from then? max clock is 20MHz, so can set high speed You have to slow down the communication in this case then: SPI.setClockDivider(SPI_CLOCK_DIV8); // max speed is 3MHz, we choose 2MHz Does that change anything?
|
|
|
|
|
64
|
Using Arduino / Programming Questions / Re: spi 9bit eeprom address can only see addr 0x00?
|
on: May 08, 2013, 04:18:49 am
|
Just to be sure we don't get problems from operator priority, please try this version too: //4k e2prom and cpu supervisor
#include <SPI.h> #define WRITE 2 #define READ 3 #define WREN 6 #define RDSR 5 #define WRSR 1
unsigned int address = 0x01; byte outval = 250; byte invalue;
void setup(){ Serial.begin(9600); Serial.println("RESET");
// set up to match device datasheet SPI.begin(); // sets up pin modes etc. SPI.setBitOrder(MSBFIRST); SPI.setDataMode(SPI_MODE0); SPI.setClockDivider(SPI_CLOCK_DIV2); // max clock is 20MHz, so can set high speed
// Enable writing digitalWrite(SS, LOW); SPI.transfer(WREN); digitalWrite(SS, HIGH);
// Initialize status register digitalWrite(SS, LOW); SPI.transfer(WRSR); SPI.transfer(0x00); digitalWrite(SS, HIGH);
// Latch enable write again (don't know why this is necessary) digitalWrite(SS, LOW); SPI.transfer(WREN); digitalWrite(SS, HIGH);
// write a value to address 0x01 digitalWrite(SS,LOW); SPI.transfer(WRITE | ((address & 0x0100) ? 8 : 0)); SPI.transfer(address & 0xFF); SPI.transfer(outval); digitalWrite(SS, HIGH);
// read a value from address 0x01 digitalWrite(SS,LOW); SPI.transfer(READ | ((address & 0x0100) ? 8 : 0)); SPI.transfer(address & 0xFF); invalue = SPI.transfer(0x00); digitalWrite(SS,HIGH); Serial.print("Read Data = "); Serial.println(invalue,DEC); }
void loop() { }
|
|
|
|
|
68
|
Using Arduino / Project Guidance / Re: Serial Communication Issue
|
on: May 08, 2013, 04:02:56 am
|
|
Did you activate software SPI in Sd2Card.h? If you did, that would explain your misses because interrupts are disabled during SPI transfers. Otherwise I currently cannot explain it. I probably would try to increase the serial buffer to a value greater than 79 bytes to be sure the buffer can hold a complete record.
|
|
|
|
|
69
|
Using Arduino / Project Guidance / Re: MAX485, serial and programming port
|
on: May 08, 2013, 03:45:11 am
|
I'm using an Arduino Pro Mini 328 from SparkFun. Any guidance on determining which pins and which timer I can use for AltSoftSerial? The Pro Mini should behave like a standard UNO in this context. That means the pins are D8 and D9 and you loose PWM on pin D10.
|
|
|
|
|
71
|
Using Arduino / Programming Questions / Re: Serial.flush on arduino mini??
|
on: May 08, 2013, 03:24:53 am
|
while (Serial.available()) Serial.read(); ... does empty your incoming buffer. But your description sounds like you're having another problem. Is it possible that you have a loopback at the serial interface? Does it work if you don't print out the same character as you're receiving?
|
|
|
|
|
72
|
Using Arduino / Programming Questions / Re: spi 9bit eeprom address can only see addr 0x00?
|
on: May 08, 2013, 03:00:27 am
|
this is what interil told me to look at, i cannot however translate this to arduino Looks like the chip has to be initialized a bit further before being ready: //4k e2prom and cpu supervisor
#include <SPI.h> #define WRITE 2 #define READ 3 #define WREN 6 #define RDSR 5 #define WRSR 1
unsigned int address = 0x01; byte outval = 250; byte invalue;
void setup(){ Serial.begin(9600); Serial.println("RESET");
// set up to match device datasheet SPI.begin(); // sets up pin modes etc. SPI.setBitOrder(MSBFIRST); SPI.setDataMode(SPI_MODE0); SPI.setClockDivider(SPI_CLOCK_DIV2); // max clock is 20MHz, so can set high speed
// Enable writing digitalWrite(SS, LOW); SPI.transfer(WREN); digitalWrite(SS, HIGH);
// Initialize status register digitalWrite(SS, LOW); SPI.transfer(WRSR); SPI.transfer(0x00); digitalWrite(SS, HIGH);
// Latch enable write again (don't know why this is necessary) digitalWrite(SS, LOW); SPI.transfer(WREN); digitalWrite(SS, HIGH);
// write a value to address 0x01 digitalWrite(SS,LOW); SPI.transfer(WRITE | (address & 0x0100) ? 8 : 0); SPI.transfer(address & 0xFF); SPI.transfer(outval); digitalWrite(SS, HIGH);
// read a value from address 0x01 digitalWrite(SS,LOW); SPI.transfer(READ | (address & 0x0100) ? 8 : 0); SPI.transfer(address & 0xFF); invalue = SPI.transfer(0x00); digitalWrite(SS,HIGH); Serial.print("Read Data = "); Serial.println(invalue,DEC); }
void loop() { }
What's the output of this sketch?
|
|
|
|
|
73
|
Using Arduino / Project Guidance / Re: SCR gate controller circuit
|
on: May 07, 2013, 01:13:05 pm
|
|
How did you connect the sine wave to the Arduino? Is the sine wave going from 0V to 5V or from -5V to 5V?
delayMicroseconds() can be called with values up to 13107, if you call it with higher value you'll have a bit overrun. So calling it with 14108 is about the same as calling it with 1000.
|
|
|
|
|
74
|
Using Arduino / Project Guidance / Re: MAX485, serial and programming port
|
on: May 07, 2013, 12:58:40 pm
|
Great, thanks for the info. I'll use softserial for the RS485 comms then. My needs are very simple but I need to be able to program with the MAX485 connected. SoftwareSerial is not a drop-in replacement for a hardware serial interface. Reliable communication is possible up to 9600 baud, in some cases up to 38400 baud. During the transfer of a byte over the SoftwareSerial interface (independent of the direction) the processor is completely absorbed and cannot be used for anything other. If you can live with this, use the SoftwareSerial. Otherwise you might take a look at the AltSoftSerial library ( http://www.pjrc.com/teensy/td_libs_AltSoftSerial.html) or use another Arduino model (Leonardo or Mega) which has more hardware serial interfaces.
|
|
|
|
|