Show Posts
|
|
Pages: [1] 2 3 ... 25
|
|
3
|
Using Arduino / Networking, Protocols, and Devices / Re: Long Range Communications
|
on: July 31, 2011, 07:31:34 am
|
|
The problem is if you want to get 11km, no one can be on that frequency for around 30km2.
Because one point is north and the other point 11km south, they could be a stronger signal a little more to the north or one a little more to the south of you.
I was a radio ham and an 11km jump at 9k6 was not possible, to me the only way is by telephone ( Wifi ) or mobile phone. I not sure about your country , but anything which would go that far would by licensed.
|
|
|
|
|
4
|
Using Arduino / Networking, Protocols, and Devices / Re: I2c Slave mode.
|
on: July 30, 2011, 05:56:32 pm
|
Hi Nick, I`m using address 8 for the master on the flyport, so I do know about the shift. I am triggering the requestEvent !!! , but like I said, I can`t use :- start ( write address ) , send data , restart ( write address + 1 ) , read data , stop . I`ve found I need to use :- start ( write address ) , send data , stop , start ( write address + 1 ) , raed data , stop. I also needed to add a couple of ms wait between the stop start. I`ve got it working now , I`ll see if it still working when I start adding code in requestEvent. what it is sending or expecting to receive I know how the program for the arduino better than for the pic chips , so I`m using it as a co-pro , plus move some load away from the flyport. The flyport has zero documentation, so been able to use the arduino is a good fall back tool.
|
|
|
|
|
5
|
Using Arduino / Networking, Protocols, and Devices / Re: I2c Slave mode.
|
on: July 30, 2011, 07:57:11 am
|
Hi Nick, oh yes I know that one, I don`t have a walk in wardrobes I have a walk in project bins. A Morse key are a radio ham? . I`m getting something back if I split the parts up with a long wait inbetween. But very hit and miss . My code is cut down , just for testing , so not a lot can go wrong #include <Wire.h>
int cmd; byte return_value = 0;
void setup() { Wire.begin(4); // join i2c bus with address #2 Wire.onRequest(requestEvent); // register event Wire.onReceive(receiveEvent); // register event Serial.begin(9600); // start serial for output }
void loop() { // check serial port etc delay(100); }
// send a reply / data back to the master void requestEvent() { switch (cmd) { case 4: Wire.send("hello - cmd 4 "); break; // default: Wire.send("DEFAULT "); break; } } // get some data from the master void receiveEvent(int howMany) { int counter = 0; return_value = 0; cmd = Wire.receive();
switch (cmd) { case 2: break; case 3: break; case 4: break; case 5: break; case 6: break; case 7: break; } }
|
|
|
|
|
7
|
Using Arduino / Networking, Protocols, and Devices / Re: I2c Slave mode.
|
on: July 29, 2011, 06:08:08 am
|
|
Thanks wayneft , you are right.
The Arduino is a little non-standard, in that it doesn`t support the , Start , send data , restart + 1, read data , stop method. I have to make them two separate commands :- start , send data , stop start + 1 , read data , stop
thanks again peter
|
|
|
|
|
8
|
Using Arduino / Networking, Protocols, and Devices / Re: I2c Slave mode.
|
on: July 29, 2011, 03:11:52 am
|
Also does your flyport give any type of return No , but the library is just talking to the internal register , so If you know what you was doing ( which I don`t ) I guess you could quickly make a new command to return any flag. The is the flyport library for i2c . /** \defgroup I2C @{ The I2C library allows the user to communicate with external devices with I2C bus, like flash memories or sensors. The Flyport is initialized as I2C master. */
/** * I2CInit - Initializes the I2C module. * \param None * \return None */ void I2CInit(BYTE I2CSpeed) { TRISGbits.TRISG2 = 1; TRISGbits.TRISG3 = 1;
I2C1TRN = 0x0000; I2C1RCV = 0x0000; I2C1BRG = I2CSpeed; // Set I2C module at 100 KHz I2C1CON = 0x8200; // Configuration of module }
/** * I2CStart - Sends a start sequence on the bus. * \param None * \return None */ void I2CStart() { I2C1CONbits.SEN = 1; // Sends a start sequence on I2C bus while(I2C1CONbits.SEN); // waits the end of start
}
/** * I2CRestart - Sends a repeated start sequence on the bus . * \param None * \return None */ void I2CRestart() { I2C1CONbits.RSEN=1; // Sends a repeated start sequence while(I2C1CONbits.RSEN); // waits the end of restart
}
/** * I2CStop - Stops the trasmissions on the bus. * \param None * \return None */ void I2CStop() { I2C1CONbits.PEN=1; // Initiate a Stop condition on the bus while(I2C1CONbits.PEN); // waits the end of stop }
/** * I2CWrite - writes one byte on the bus. * \param None * \return None */ void I2CWrite(BYTE data) { I2C1TRN = data; // Sends a byte on the bus
while(I2C1STATbits.TRSTAT || I2C1STATbits.TBF); // waits the end of trasmissions // Idle while(I2C1CONbits.SEN || I2C1CONbits.PEN || I2C1CONbits.RCEN || I2C1CONbits.RSEN || I2C1CONbits.ACKEN);
}
/** * I2CRead - Reads one byte from the data bus . * \param None * \return None */ BYTE I2CRead(BYTE ack) { I2C1CONbits.RCEN=1; // Reads one byte from the bus while(I2C1CONbits.RCEN); // waits the end of the read I2C1STATbits.I2COV = 0; // Resets the overflow flag I2C1CONbits.ACKDT = ack; I2C1CONbits.ACKEN = 1; // Initiate an aknowledge sequence while(I2C1CONbits.ACKEN); // wait the end of the acknowledge sequence return I2C1RCV; // Returns the byte } /*! @} */
|
|
|
|
|
9
|
Using Arduino / Networking, Protocols, and Devices / Re: I2c Slave mode.
|
on: July 28, 2011, 11:25:12 am
|
For the arduino side I`m just using the example wire/slave_sender , on the master side I`m using what flyport uses to handle i2c , which is very literal. Which would go something like this on the flyport :- ( My code from read a adc chip , which works ) http://www.byvac.com/bv3/index.php?route=product/product&path=54&product_id=77 I2CStart ( ); I2CWrite ( adc ); // the i2c address , * 2 from the arduino address used. I2CWrite ( 0x04 ); // the command reg used I2CRestart ( ); I2CWrite( adc + 0x01); high = I2CRead(0); low = I2CRead(1); // ack 1 = last byte I2CStop ( ); Not sure how or if that help , The problem is that the “void requestEvent()” is never triggered
|
|
|
|
|
10
|
Using Arduino / Networking, Protocols, and Devices / Re: I2c Slave mode.
|
on: July 28, 2011, 05:59:07 am
|
|
Hi , 9 days without a reply must means that :-
a / not I lot of people use i2c b/ not a lot of people use the arduino in i2c slave mode c/ No one uses the arduino in i2c slave mode connected to any device other than a second arduino
|
|
|
|
|
11
|
Using Arduino / Networking, Protocols, and Devices / I2c Slave mode.
|
on: July 19, 2011, 04:30:41 pm
|
|
Hi, trying to get an Arduino in slave mode to send back data to a Flyport in master mode. I can give the Arduino data, but the i2c restart, and ask for data is not working. ( I`ve had it working between “Arduino to Arduino”, but not “Arduino to !Arduino”
I`ve put a print statement in "void requestEvent()" and it`s never called !!!
Is there a better slave library for the Arduino ?
Thank in advance Peter A
|
|
|
|
|
12
|
Forum 2005-2010 (read only) / Troubleshooting / Re: How much sram is still free?
|
on: October 21, 2009, 01:42:48 pm
|
|
8192 is the 8k sram of the mega is change for the 2k of the 328.
Serial.print("free memory = "); Serial.print(availableMemory()); Serial.print(" - memory used = "); Serial.println(8192-availableMemory());
int availableMemory() { int size = 8192; byte *buf; while ((buf = (byte *) malloc(--size)) == NULL); free(buf); return size; }
|
|
|
|
|