Go Down

Topic: Data transfer through ArduinoMega (Read 278 times) previous topic - next topic

Robin2

I have tried other method and it is working!
I have ditched the arduino's serial comms as it was using TTL method.
Instead, I used the digital pins of arduino and voila! It is working!
The serial pins are digital pins. All the Arduino pins are digital pins. A few of them can also use the ADC to read voltages. It would make future testing much easier if you had left the connections on the I/O pins that are used by Serial1 and Serial2

Your simple bit-banging program has no intelligence so there can be no means to alter the messages.

Quote
So I assume data needs to be sent back and forth in precise timing.
I mentioned this indirectly in Reply #13.

If you want to be able to alter the messages then you need to use Serial to interpret the messages. Your Mega will need to receive the full message from the Front device and send a completely different message to the Back device. That will inevitably change the timing from what the two devices are used to.

As far as I can see your programs to date have simply received a character and sent a character without any attempt to show you (the human) what is in the message. Finding out what is in the messages MUST be the first step. And that applies for the message coming from both devices.

By the way there is no certainty that, after all the investigation, it will actually be possible to change the behaviour of the machine - it may be that everything you try will result in a Comms Failure. It could be that the pair of devices are programmed with a very tight timeout limit for a response to messages and anything substantial that you do will upset that.

I suppose a possible option would be to replace the front unit completely with the Mega - but that would not be a simple task, especially as you would have to make your own control panel and understand in detail how the whole machine is designed to operate.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

imbatronics

#16
Jan 22, 2020, 02:31 pm Last Edit: Jan 22, 2020, 02:32 pm by imbatronics
Hi Robin

I have very little knowledge of how electronics work. So I actually don't have any idea how stuff works.
I am trying everything to achieve 'if it works, it works'. Which is not ideal, but I am learning on the way + get a functioning machine.

I have contacted the manufacturer and they are actually willing to disclose some information.
I would need to email them with lists of things I need to know to achieve my goal, the manufacturer will check if it is okay to disclose the information.
Apparently the machine is discontinued, hence they can disclose some info.

Hopefully with their disclosed information, we could tackle this project much easier.

Could you please tell me what information I need from the manufacturer?
It would be greatly appreciated if you could list them.

imbatronics

#17
Jan 22, 2020, 02:49 pm Last Edit: Jan 22, 2020, 05:27 pm by imbatronics
I am trying to convert code I have made to serial.
But it is not working.

Code: [Select]

int data1 = 0;
int data2 = 0;
int baud = 9600;
void setup()
{
  Serial1.begin(baud);
  Serial2.begin(baud);
}
void loop()
{
  // send data only when you receive data:
  if(Serial1.available() > 0)
  {
    data1 = Serial1.read();
    //Serial2.write(data1);
  } 
  if(Serial2.available() > 0)
  {
    data2 = Serial2.read();
    //Serial1.write(data2);
  }
 
  Serial2.write(data1);
  Serial1.write(data2);
}


After I wire it up, the machine does not display error 'comms error' but gets 'stuck' or freeze.

Is the above code Serial equivalent of my code in the previous reply?
Or have I done something wrong?


***Edit: I just realized that Serial pins have resting voltage of 5v.. hence should obviously not work..


Robin2

Could you please tell me what information I need from the manufacturer?
It would be greatly appreciated if you could list them.
You are racing ahead of me again. Please wait for a Reply to one question before starting another. Maybe take a little time to decide which question should be asked (and answered) first rather than rushing to write 2 or 3 Replies.

I don't honestly know how to answer this question. Have you explained clearly to the manufacturer what you are trying to do? If what you want to be able to do is change the command messages that travel from the Front to the Back then you need a complete list of the command messages and the expected responses to each of them.

Quote
After I wire it up, the machine does not display error 'comms error' but gets 'stuck' or freeze.
The correct way is to re-instate the two commented-out Serial lines and delete the last two lines.

However this still is not going to let YOU see what is happening. Have a look at the examples in Serial Input Basics - simple reliable non-blocking ways to receive data. You need to have a version (probably from the second example) for reading both Serial1 and Serial2 and displaying the output on the Serial Monitor using Serial. And rather than sending characters one at a time to the Back you should send the whole message that has been collected.

Start by using my Tutorial code to read a message from the Front - never mind about sending it onwards. It is entirely possible that the messages use binary data rather than text - but start by doing some basic tests and see what happens.

...R



Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up