Show Posts
Pages: 1 [2] 3 4 ... 11
16  Using Arduino / Programming Questions / Connect several devices to the same serial port, multiplexing technique on: August 29, 2012, 01:04:00 pm
Hi all!

I'm doing the brainstorming thing, I need to multiplex my PC serial port in several remote serials ports that let me connect several SCADA devices.

The problem is that the SCADA device and the software of this device and the firmware do not support device ID,headers or similar. All designed to connect only one device for each serial port at the computer.

The only idea that I get is add some header to the data and then send it at the common serial and let to the remote Arduino decide if the packet id addressed to him print this data at the serial output, for the opposite way the Arduino picks the data add his local header and then print in the main serial.

Think in several devices connected via RS-485 and and several Arduinos connected to this BUS, We have other way to do this? to multiplex a serial port?

Best Regards
Frank
17  Using Arduino / Programming Questions / Re: Implement Serial over Ethernet using RFC 2217 standard on: August 21, 2012, 03:03:22 pm
Yeap, In some cases like these is more easy write your-own-protocol that code a existing one.
What is not clear is what the set the port parameters, like speed or control lines. And other issue is how to detect data from control commands.

In the mayor cases I think that is better use two ports, one for raw data and other for control, this is like re-invent the wheel because the serial port use this idea.

It's strange that cisco's note, because if you use binary data and not only text how you will decode if is a data control packet or raw data?.

I'm go to use to different ports and ready! I will apply the less-effort-law!!!

Best Regards!
Frank
18  Using Arduino / Programming Questions / Implement Serial over Ethernet using RFC 2217 standard on: August 20, 2012, 06:50:32 pm
Hi all!!

I want to implement Serial over Ethernet using the RFC-2217 specification.
Now someone have some code about this? only about the set-up of the RFC because after there do not so difficult, almost if we do not encrypt the sockets.

I found the original spec from CISCO:
http://www.faqs.org/rfcs/rfc2217.html#b

If the code is basic will be better so I can test is in some VB

Best Regards
Frank
19  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
20  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
21  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
22  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


23  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
24  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
25  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
26  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
27  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
28  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
29  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
30  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


Pages: 1 [2] 3 4 ... 11