Go Down

Topic: Query please guide (Read 687 times) previous topic - next topic

streetHawk

Hi,

I am having some queries regqrding the M DB protocol , in the specification the peripheral addresses are defined as

00001xxx (08H) for eg a changer : upper 5bits[7,6,5,4,3] are used for addressing and lower 3bits[2,1,0] for commands.

Suppose i need to send a Poll command (0BH) to the changer peripheral how should i construct the word.

(00001xxx | 0xB) = 0xB

00001xxx
00001011
--------
00001011 (0B)
--------

Am i intrepreting correctly. Also do i need to send this with the mode bit (9th bit) set as address and is there any checksum to be sent after the poll command on the serial bus.Please suggest.

Hwk



johnwasser

Your problem there is that 0x0B doesn't fit in three bits.  :(

Do you have a pointer to the documentation?  Perhaps someone else reading the document would be able to interpret it for you.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

robtillaart


from the example I assume the Poll command is 0B00000011 iso 0xB  ==> ANDing 0B00000011 with 0B00001xxx gives 0B00001011 = 0x0B


00001xxx
00001011
--------
00001011 (0B)

if the operation is an OR the answer could also be 00001111 !  if the first x would be an 1 (by accident or ...)



The proper way to OR the addresses and commands is

WORD = ((ADDR<<3) & 0B11111000) | (CMD & 0B00000111);

as the address is often just zero based, and the command is 0..7 the optimized Arduino code will look something like

int w = (address << 3) | command ;

(does this make sense to you?)



Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

streetHawk

Thanks for the response John & Robtillaart,

The document I'm referring to is this link
http://www.vending.org/technology/MDB_Version_4.pdf

Please refer to this document On pg-11 the addresses are detailed and pg-14 depicts a Typical session example & Pg-29 lists all the cmd .

Based on this what is ur suggestion

robtillaart

from the PDF
Address Definition
00000xxxB (00H) Reserved for VMC
00001xxxB (08H) Changer
00010xxxB (10H) Cashless Device #1
00011xxxB (18H) Communications Gateway
00100xxxB (20H) Display


The B just stands for Binary on page 29. so it is not the hex value 11.




2.1 Byte Format
Tte protocol sends a byte with the address first and then a (POLL) command as a separate byte.

The Mode bit, which is bit 9(!),  defines if the byte is to be interpreted as an address or a command.

The MOde bit is also used to indicate EndOfPacket (Slave to Master)


Baud Rate: 9600 NRZ
Serial Bit Format:
1 Start Bit
8 Data Bits
1 Mode Bit
1 Stop Bit
-------------
11 Bits Total

Start 0 1 2 3 4 5 6 7 Mode Stop

Mode Bit: Master-to-Peripheral
The mode bit differentiates between ADDRESS bytes and DATA bytes. ADDRESS
bytes must be read by all peripherals, DATA bytes are only read by the peripheral that
has been addressed.
The mode bit is set (logic one) to indicate an ADDRESS byte, and not set (logic zero) to
indicate a DATA byte.

Mode Bit: Peripheral-to-Master
The mode bit must be set on the last byte sent when data is sent from a Slave to the
Master


This is NOT covered by the standard Arduino Serial communication, there are other libs that support 9 bits (search the forum).

To send the poll command you should send 2 bytes

0000 1xxx 1 (address of device + mode bit set)
0000 1101 0 (poll command + mode bit off)

paragrah 5.3 explains the responses of the device ....




Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

streetHawk

Thanks for your reply Robtillaart, I appreciate it. But i am again lost :(

---- pg 26 -----
The upper five bits (MSB) of the Address Byte will be used for addressing. That is, bits
7,6,5,4,3 of the previous byte description will be used for addressing.

The lower three bits (i.e. 2,1,0) of the Address Byte will contain peripheral specific
commands. This will allow up to eight instructions to be embedded in the first byte of a
block.

----------------------------------------------------

So Poll is a command and not a data; Does it mean poll command (0x0b) has to fit into this 3 bits ? how do i do it ?


Also in the section 2.5

VMC:
      ------- ADD*---- CHK-----------
Peripheral:
-------------------------------------ACK*------------

*Indicates mode bit set


This is a typical case when i need to send a poll command, there doesnt seem to be any data byte. so how do i send the poll command, please help im very confused here.

Hwk

robtillaart

Quote
So Poll is a command and not a data; Does it mean poll command (0x0b) has to fit into this 3 bits ? how do i do it ?

It cannot as B = 1011 so it need 4 bytes. => conclusio => POLL should be send seperately ,

unfortunely I don't have such device to test :(
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up