one issue I ran into and i’m not sure why…
if I use this code in a while loop, the mainboard looses the connection to the module and throws an exception:
bool jay = true;
jay = !jay;
Thread.Sleep(100); //if I remove the sleep it stops instantly.. if I increase the time it runs longer but eventually looses the connection...
genericDaisylink.WriteRegister(0x1, (byte)(jay ? 1 : 0));
here is the setup of the upstream port only which is working but not stable if the loop is tight and both are running off of the same Computer (power source)…
so if I move the Arduino to a battery power, things get better but I can only get the loop to run with a minimum of Thread.sleep(50); anything below that will cause the line to get lost… my guess is NOISE on the lines…
Do you know how would I send data from the Arduino to the Mainboard?
I can’t seem to find the how to?
another i’m confused about…
also, say I want to send a string from Mainboard to slave and back …
would I have to create my own start register and stop register and connate the bytes to complete the transmission ?
is that how it should be done?
@ Jay Jay - The daisy link protocol does not cater to sending data to the mainboard. From the mainboard you either read from or write to registers on the DL device, but what is not immediately obvious is that the registers are not limited to one byte. if you take a look at the DL40IO firmware, you will see that I have multi byte registers, so you could have a register that you write your string to and another register that you read the response from.
In cases that you want the DL device to “send” data to the mainboard, you can put the data in a register and raise an interrupt which triggers the mainboard to read the data register. If you need more control you can have a status register that the mainboard will read when it receives the interrupt, the status register will indicate what it was that caused the interrupt and therefore what the mainboard needs to go read etc.
That is the correct code, you will see ReadUInt32/64 etc. as well, each of these are reading multiple bytes from a single register. On the firmware side, DL40.c contains a function called DL_Platform_ReadRegister, this function takes the register and the offset into the register as arguments, for a multi-byte read the function is called with the same register but with an increasing offset. The Arduino firmware would need similar support for reading registers.
So you could for example encode the string as a length prefixed string, the the first byte might be the length and the subsequent bytes the characters in the string. Of course if you need more than 255 characters you could use a multi-byte prefix.
That means you have to release it after waiting for 1ms. But before that you have to change the bit in the config register, so the mainboard can read it and distinguish your module as the source of the interrupt.
Most likely you will need to do more than that, unless there is only one type of interrupt in your module.
Raising interrupts on the module side is quite intricate, you need to take the neighboring bus state into account. It might help to use the DL40IO implementation as a reference.
Take a look at DL_Interrupt() in DaisyLink.c. this function initiates the interrupt and records sets a flag indicating that we are controlling the bus. In the same file the DL_Process() function is responsible for resetting the state and the bus if this module is driving the bus, see the STATE_ACTIVE case in the code, the main procedure calls DL_Process() in a loop, so this function is being called continuously.
I have not looked at the Arduino implementation, so I do not know how well this matches the implementation, there are many ways to achieve this. I hope it can at least give you an idea of how the protocol specification regarding interrupts can be translated to code.