Show Posts
Pages: 1 [2] 3 4 ... 10
16  Using Arduino / Networking, Protocols, and Devices / DNP3 over serial port how to start ? on: August 16, 2012, 02:43:18 pm
Hi all!

What I want to do is easy
I want to wrote a DNP3 profile and use it like protocol over a serial link between a PC and a Arduino.

I'm trying to decode a comercial device that use DNP3 and it have a defined DNP3 profile.

like this:http://www.qtech.co.nz/site/qtechdata/files/Technical%20Manuals%20etc//DATRAN%20XL4%20DNP3%20RTU%20-%20Device%20Profile%20v1.pdf

Now from here to the serial stream...what I need to do? I can't found the skeleton of this protocol to use in a serial link.

Best Regards
Frank
17  Using Arduino / Programming Questions / Re: using RFM22 library in framing mode (more than 64bytes packets) on: August 14, 2012, 10:25:19 am
Hi Paul!
The packet size is the buffer value (500)
And the frame RF22_MAX_MESSAGE_LEN is a 128 byte size.

The data that I'm reading do not have blank spaces, what I see about the transmitter is that it needs more time to send the 3 frames.

I will test is in a mega 128, this have a lot of RAM so I can discard if the problem comes from it.
Other idea is process the data at the incoming frame but I think that some data field is partial from the actual frame to the next, I mean is divided in to different frames.

I will try the same but in a bigger uP or using only datagram and not reliabledatagram

Best Regards!
Frank
18  Using Arduino / Programming Questions / using RFM22 library in framing mode (more than 64bytes packets) on: August 13, 2012, 10:38:21 pm
I'm trying to send more than 64 bytes over radio using the RFM22 modules. Now my transmitter looks great but for some reason the receivers fails after several successfully receptions.

I was test the transmitter printing all the data every time that the receivers get a valid frame.

I only want to concat this frame in another to get almost 400 bytes packet.

Now my code:

Code:
RF22ReliableDatagram rf22(MyNODEID,CHIP_SS,RFM22_INT);


uint8_t  buffer[500];
uint16_t buffer_index=0;
uint16_t tiempo_ultimo_rx=millis();



Code:
void loop(){
    uint8_t buf[RF22_MAX_MESSAGE_LEN+1];
    uint8_t len = sizeof(buf);
    uint8_t from;
    uint8_t to;
    uint8_t id;

    if (buffer_index >= 400){buffer_index=0;}
   
    if(millis() - tiempo_ultimo_rx >= 200) {buffer_index=0;}
   
    if (rf22.recvfromAckTimeout(buf, &len, 1000, &from, &to, &id)){
       for (int i=0; i<len; i++){
         buffer[buffer_index+i] = buf[i];
         //Serial.write(buf[i]);
         tiempo_ultimo_rx=millis(); 
         }
       
    buffer_index = buffer_index +len;
    Serial.println(buffer_index,DEC);
    }
}


This code only concat all the frames into a local buffer, and after this I will proccess it.
500 bytes like buffer is too much for a ATmega 328?
It's realy strange because it work for several receptions and then fails and stay like this.
If I debug how many bytes I get into the buffer:

Right:
127 (1º first frame)
254 (2º first frame)
342 (3º first frame)

When it fails and stay like this:
127 (1º first frame) loads the firts 127 bytes
127 (2º first frame) do not load nothing
88 (3º first frame) loads the rest

I test others ways but the problem still there..

I-D-E-A-S??  smiley-mr-green
19  Using Arduino / Programming Questions / Radio modems and protocol to use (or any other rs232 link) on: July 10, 2012, 03:38:26 pm
I think that this topic was discussed several times.

What I want to do is link to computers using a Bell202 radio modem (fx614), this types of modem the only thing that they do is signalling a 1 as a 1200Hz tone and a 0 like a 2200Hz tone.
I'm reading some info about how use them in a correct way because them do not provide a clear RS-232 link because the decoder must writes on software. In some application like radio they use Manchester as encoding/decoding and Modulo-2 RZ (return to Zero) as CRC.

I have two ideas to implement this, the first one is write some rs-232 encoder/decoder using Manchester.h as encoding provider.

And the second one is use VirtualWire library and modify the code to get a transceiver and not only a transmitter or a receiver.

So? what will be better and easier??

Best Regards!
Frank


20  Using Arduino / Programming Questions / Re: Store a struct in EEPROM...why the indexing fails? on: June 21, 2012, 07:36:44 pm
Hi Peter!
The only way that I fount to get it work is this:
Code:
typedef struct RoutingTableEntry
    {
        uint8_t      dest;      ///< Destination node address
        uint8_t      next_hop;  ///< Send via this next hop address
        uint8_t      state;     ///< State of this route, one of RouteState
    } RoutingTableEntry;

And...
Code:
struct RoutingTableEntry ReadEntry(uint8_t Index){
    RoutingTableEntry mytable;
    eeprom_read_block((void*)&mytable, (void*)(Index * sizeof(RoutingTableEntry)), sizeof(RoutingTableEntry));
    return mytable;
}


void WriteEntry(struct RoutingTableEntry structure,uint8_t Index){
    eeprom_write_block((const void*)&structure, (void*)(Index * sizeof(RoutingTableEntry)), sizeof(RoutingTableEntry));
}

I don't know why but the only way that I can pass the struct at the function call is declaring both times as RoutingTableEntry.
The code is working but it's wrote in the correct way?

I have others lines like this:
Code:
uint8_t RF22Router::route(RoutedMessage* message, uint8_t messageLen)
{
    // Reliably deliver it if possible. See if we have a route:
    uint8_t next_hop = RF22_BROADCAST_ADDRESS;
    if (message->header.dest != RF22_BROADCAST_ADDRESS)
    {
RoutingTableEntry* route = getRouteTo(message->header.dest);
if (!route)
    return RF22_ROUTER_ERROR_NO_ROUTE;
next_hop = route->next_hop;
    }

    if (!RF22ReliableDatagram::sendtoWait((uint8_t*)message, messageLen, next_hop))
return RF22_ROUTER_ERROR_UNABLE_TO_DELIVER;

    return RF22_ROUTER_ERROR_NONE;
}

I think that
Code:
message->header.dest
means that it evaluate the dest variable from the message's header rigth?
And this:
Code:
next_hop = route->next_hop;

This loads the next_hop element...but where goes that value? looks that never store it?

Best Regards!!
Frank
21  Using Arduino / Programming Questions / Re: Store a struct in EEPROM...why the indexing fails? on: June 21, 2012, 10:31:19 am
Sonow the functions looks like this:

Code:
void WriteEntry(struct RoutingTable structure,uint8_t Index){
    RoutingTableEntry = structure;
    eeprom_write_block((const void*)&RoutingTableEntry, (void*)(Index
* sizeof(RoutingTableEntry)), sizeof(RoutingTableEntry));
}

struct RoutingTable ReadEntry(uint8_t Index){
    eeprom_read_block((void*)&RoutingTableEntry, (void*)(Index *
sizeof(RoutingTableEntry)), sizeof(RoutingTableEntry));
    return RoutingTableEntry;
}

But the structure definition is this:
Code:
    struct RoutingTable
    {
        uint8_t      dest;     
        uint8_t      next_hop; 
        uint8_t      state;     
    } RoutingTableEntry;

Now can I declare it and operate it as a typedef?, like this:

Code:
    typedef struct
    {
uint8_t      dest; 
uint8_t      next_hop;
uint8_t      state; 
    } RoutingTableEntry;


What I need to re-declare?
Best Regards!!
Frank
22  Using Arduino / Programming Questions / Store a struct in EEPROM...why the indexing fails? on: June 19, 2012, 11:10:37 pm
Hi all!

I want to store several struct instances at the internal EEPROM memory, for testing I wrote this code:

Code:
#include <avr/eeprom.h>

struct settings_t
{
  uint8_t first;
  uint8_t second;
  uint8_t third;
} settings;


void setup()
{
  Serial.begin(9600);
  delay(100);
 
  for (int i=0;i<2;i++){
    settings.first = 'A';
    settings.second = 'B';
    settings.third = 'C';
    eeprom_write_block((const void*)&settings, (void*)i, sizeof(settings)); }
    delay(10);

 
}

void loop()
{
  for (int j=0;j<2;j++){
  eeprom_read_block((void*)&settings, (void*)j, sizeof(settings));
 
  Serial.write(settings.first);
  Serial.write(settings.second);
  Serial.write(settings.third);
  Serial.println();
 
  }
 
  delay(1000);
}

For some reason the print of this code get me this:

Code:
AAA
AAA
AAA
AAB
ABC

What can be wrong?

In fact what I'm looking for are two functions to save/restore my struct by indexing several instances:
(Is like to have a struct mystruct[100] but not in RAM stored in EEPROM).

Code:
void WriteEntry(struct settings_t structure,uint8_t Index){}

struct settings_t ReadEntry(uint8_t Index){}

Best Regards!
Frank
23  Using Arduino / Microcontrollers / Re: requirements and limits of 8Mhz 3.3v on: May 23, 2012, 03:42:09 pm
Hi Jack!
Can you send me the source code of this optiboot version? I want to know if the watchdog are implemented.

I will upload using the Arduino as burner.

What winAVR version do you use to build it?

Best regards!
Frank
24  Using Arduino / Microcontrollers / Re: ATMEGA 328 watchdog....new bootloader or re-code the actual ? on: May 21, 2012, 06:41:18 pm
Something else is the correct answer!.
And the ELSE is the best description to my boards, I really love this platform so every time that I like to start some project I design and then build my own pcb.

Is less headaches with the wires and connections, for little wild time I'm using 8MHz and sometimes 3V3 and others 5V as PS

In fact I think that is not a good idea use a 16MHz crystal I prefer use a TCXO or similar for higher frequencies.

It's what I like, if the application don't control AC charges or similar do not happens nothing but.... why to test !!

I got some experience too with the Wiring platform doing some small mods to the bootladers about this PS and clocks.

Best Regards!!
Frank
25  Using Arduino / Microcontrollers / Re: ATMEGA 328 watchdog....new bootloader or re-code the actual ? on: May 21, 2012, 01:50:17 pm
Hi Nick!
Is the opti ready to upload it a 328 with 3V3 PS and 8Mhz as clock?
The source code of this bootloader are in the download section of the site right?

Best Regards!
Frank
26  Using Arduino / Programming Questions / Re: debugging objects and some others about arrays on: May 20, 2012, 01:51:52 pm
Can i leave this sign-extension value or is better try to found who produce it to set like an unsigned value?
It's my first time wih the sing-extension situation!

Best Regards
Frank
27  Using Arduino / Programming Questions / debugging objects and some others about arrays on: May 20, 2012, 01:25:39 pm
Hi all!
I'm working with the RFM22 library from Mike McCauley, the library works great but when I use it to build a datagram network it fails after some time, and I wrote some VB application to analize what is wrong with it.

Now when I dump the datagram object I fount a hex value like this: FFFFFF84
I mean i get the data byte per byte, like this:
Code:
0F 0A 01 FFFFFF84 00 02 0D ....


What can be this FFFFFF84 value? a mem pointer could be?

And other issue is about an array, is this valid ?

Code:

uint_8t my array [255];
mifunction (array,&lenarray); // this is a function that fills the arrays with 200 values and lenarray let me know with how many was filled

//and then i add more values to the arrar
myarray[lenarray] = 201;
myarray[lenarray+1] = 202;
myarray[lenarray+2] = 203;

lenarray = lenarray+3;


Is this code correct? it's working but is this codding the right way to add member to the array?

Best Regards!
Frank


28  Using Arduino / Microcontrollers / Re: ATMEGA 328 watchdog....new bootloader or re-code the actual ? on: May 19, 2012, 11:46:35 am
Hi Nick!!

Was that missing #define, now works great and the uP reset by itself and runs again without any issues, i will let it with the watchdog reset mechanism to test if it reset and restart correctly for a several hours.

Best Regards!
Frank
29  Using Arduino / Microcontrollers / Re: ATMEGA 328 watchdog....new bootloader or re-code the actual ? on: May 18, 2012, 09:00:48 pm
At the bootloader code and makefile i found this:

'-DWATCHDOG_MODS'

making reference to the C code:

Code:
/* main program starts here */
int main(void)
{
uint8_t ch,ch2;
uint16_t w;

#ifdef WATCHDOG_MODS
ch = MCUSR;
MCUSR = 0;

WDTCSR |= _BV(WDCE) | _BV(WDE);
WDTCSR = 0;

// Check if the WDT was used to reset, in which case we dont bootload and skip straight to the code. woot.
  if (! (ch &  _BV(EXTRF))) // if its a not an external reset...
app_start();  // skip bootloader
#else
asm volatile("nop\n\t");
#endif

and the makefile script:
Code:
atmega328_pro8: TARGET = atmega328_pro_8MHz
atmega328_pro8: MCU_TARGET = atmega328p
atmega328_pro8: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' -DBAUD_RATE=57600 -DDOUBLE_SPEED
atmega328_pro8: AVR_FREQ = 8000000L
atmega328_pro8: LDSECTION  = --section-start=.text=0x7800
atmega328_pro8: $(PROGRAM)_atmega328_pro_8MHz.hex

hemm... i'm confused if de -D directive is #define rigth? so at the latest line we must add '-DWATCHDOG_MODS'
i leave the make as it and add into the C this:
#define WATCHDOG_MODS true

I got the HEX so i will burn to test, I try to decode the C code comment...
// Check if the WDT was used to reset, in which case we dont bootload and skip straight to the code. woot....Means that they do not waits for the loading sketch time...because restart without bootloader is not a nice idea!

Best Regards!
Frank
30  Using Arduino / Microcontrollers / Re: ATMEGA 328 watchdog....new bootloader or re-code the actual ? on: May 18, 2012, 08:11:19 pm
I'm using this: ATmegaBOOT_168_atmega328_pro_8MHz.hex, it's inside de atmega folder.

Best Regards!
Frank
Pages: 1 [2] 3 4 ... 10