DYNAMENT AN0007 Arduino ទៅ Platinum COMM

លក្ខណៈបច្ចេកទេស
- ឈ្មោះផលិតផល៖ ឯកសារជំនួយ ARDUINO ទៅ PLATINUM COMMS
- ក្រុមហ៊ុនផលិត:Dynament Limited
- អាស័យដ្ឋាន៖ Hermitage Lane Industrial Estate, Kings Mill Way, Mansfield, Nottinghamshire, NG18 5ER, UK
- Contact: Tel: 44 (0)1623 663636, Email: sales@dynament.com, Webគេហទំព័រ៖ www.dynament.com
- លេខ៖ ១.២ កាលបរិច្ឆេទ៖ ០៩/០៤/២០២៥
ការណែនាំអំពីការប្រើប្រាស់ផលិតផល
ភ្ជាប់ឧបករណ៍ចាប់សញ្ញា
សន្លឹកទិន្នន័យនេះប្រើ Arduino Mega ជាអតីតample. Connect as follows:
- 5v -> 5v ម្ជុល Arduino
- 0v -> Arduino GND
- Tx -> Arduino RX1
- Rx -> Goes to the output of the potential divider.
The input goes to Arduino Tx
វ៉ុលtagអ៊ីភាពឆបគ្នា
The Arduino uses 5V logic high while the Platinum Sensor uses 3.3V. Use a voltage divider with suggested values for R1 and R2 as 4K7 to prevent damage to the Sensor.
ការដំឡើង Arduino IDE
- Download the newest version of the Arduino IDE software from the Arduino webគេហទំព័រ។
- Select the Arduino board, processor, and port in the tools drop-down menu.
ការបង្ហោះកូដ
- ចម្លងឧampលេខកូដចូលទៅក្នុង Arduino IDE ។
- ផ្ទុកឡើងកូដទៅ Arduino ដោយចុចព្រួញ។
- បើកម៉ូនីទ័រសៀរៀលទៅ view ការបញ្ជូនទិន្នន័យ។
ភ្ជាប់ឧបករណ៍ចាប់សញ្ញា
សន្លឹកទិន្នន័យនេះប្រើ Arduino Mega ជាអតីតampលេ Ardunio Mega ផ្តល់ច្រក comm ច្រើនជាងមួយ ដូច្នេះច្រក comm 1 ត្រូវបានប្រើដើម្បីទំនាក់ទំនងជាមួយឧបករណ៍ចាប់សញ្ញា ហើយច្រក comm 0 ត្រូវបានប្រើដើម្បីបោះពុម្ពទៅកុំព្យូទ័រ។
Arduino ប្រើ 5v logic high ចំណែក Platinum Sensor ប្រើ 3.3v ដូច្នេះដើម្បីការពារការខូចខាតដល់ Sensor មួយវ៉ុល។tage divider must be used. Suggested values for R1 and R2 are 4K7Ω.

The Sensor transmit line going to the Arduino receive doesn’t need a divider, as 3.3V is an acceptable input to the Arduino.
To power the Sensor, it must be connected to 5V and 0V. To do this, you can use the pins on the Arduino.
After this is complete, the sensor should now have the following pins connected: 5V -> 5V Arduino pin
- 0v -> Arduino GND
- Tx -> Arduino RX1
- Rx -> Goes to the output of the potential divider. The input goes to Arduino Tx.
- After this is complete, your Platinum Sensor should be connected as shown:

- ប្រសិនបើអ្នកកំពុងប្រើ Arduino ដែលមានច្រក comm តែមួយ (ដូចជា Arduino Uno) អ្នកនឹងត្រូវភ្ជាប់វាទៅវា ប៉ុន្តែនៅពេលដែលអ្នកប្រើ serial monitor (បង្ហាញនៅពេលក្រោយ) វាក៏នឹងបង្ហាញ hex ដែលត្រូវបានបញ្ជូនផងដែរ។
Arduino IDE
Go to the Arduino website and download the newest version of the Arduino IDE software. Once installed, you should see the following screen:
In the tools drop-down menu, select the Arduino board, processor, and port you are using:
ចម្លងនៅក្នុងនេះ ឧampលេខកូដ៖
- void send_read_live_data_simple(); void receive_read_live_data_simple();
- void setup() { Serial.begin(38400);Serial1.begin(38400); }
- void loop(){send_read_live_data_simple();receive_read_live_data_simple(); delay(5000);}
- void send_read_live_data_simple(){ // 0x10, 0x13, 0x06, 0x10, 0x1F, 0x00, 0x58 Serial1.write(0x10); Serial1.write(0x13); Serial1.write(0x06); Serial1.write(0x10); Serial1.write(0x1F); Serial1.write(0x00);Serial1.write(0x58); }
- void receive_read_live_data_simple(){while (Serial1.available()) {Serial.print(Serial1.read(), HEX); Serial.print(“|”); } Serial.println(); }

- Click the arrow to upload the code to the Arduino.
- After the Arduino has been programmed, open the serial monitor.


ការពន្យល់កូដ
The Arduino IDE uses C++ to program the Arduino.![]()
- This line is a forward declaration. This is used to tell the Microcontroller that further down in the program, the ‘send_read_live_data_simple’ function and the
‘receive_read_live_data_simple’ function will be called.
- បន្ទាប់គឺមុខងារដំឡើង។ លេខកូដនេះដំណើរការតែម្តងគត់នៅពេលចាប់ផ្តើម។ វាចាប់ផ្តើមច្រក Serial0 និង Serial1។ ស៊េរី 0 គឺជាអ្វីដែលត្រូវបានបង្ហាញនៅក្នុងអេក្រង់ម៉ូនីទ័រសៀរៀល។ Serial1 គឺជាច្រកសម្រាប់ទំនាក់ទំនងជាមួយឧបករណ៍ចាប់សញ្ញា។

- This is the main loop; this code gets repeatedly looped. You can see by reading the function names that it sends a request to read a simplified version of the live data structure. Then it reads the receive port to read the reply. After this, the Microcontroller waits 5000ms.

- This function writes the request to get the live data simple struct to serial port 1. As previously mentioned, if you only have one serial port, you should change Serial1 to Serial.
To see the full list of commands, refer to the Premier sensor Communications protocol document. Here is the part of the document that tells you what to write for this command:
Read live data simply
Send the following bytes:
DLE, RD. Variable 10, OLE, EOE Checksum High byte. Checksum low byte or CRC High byte, CRC low byte, i.e. ox10, ox13, 006, ox10. oxlF, OXOO, ox58 Ox9B. Ox8F
This function loops the read function while there is still data to be received from the Platinum Sensor. Serial1.read() reads the data from Serial1 which is connected to the sensor and prints it on Serial0 so it can be seen on the serial monitor. The character ‘|’ is then printed to break up each byte that is received to make it clearer on the serial monitor.
After this is complete, it writes a new line to the serial monitor.
Packet Breakdown
Figures 8 and 9 show the output of a serial decoder connected to the receive and transmit lines.

រូបភាពទី 10 និង 11 បង្ហាញ hex ចេញនិងចូលរៀងគ្នាជាមួយនឹងជួរឈរដែលបង្ហាញថាវាជាពាក្យបញ្ជាមួយ។


សូមចំណាំថាការអានឧស្ម័នគឺជាទសភាគមិនមែនជាចំនួនគត់ទេ។ ទសភាគនេះគឺនៅក្នុងទម្រង់ IEEE-754 អ្នកអាចប្រើកម្មវិធីបំប្លែងតាមអ៊ីនធឺណិតដូចនេះដើម្បីបំប្លែងវាបាន។ តម្លៃឧស្ម័នក្នុងករណីនេះបង្ហាញ -250 (ដូចដែលវាស្ថិតនៅក្នុងរបៀបកំហុសនៅពេលនោះ) ។
ការប្រើប្រាស់ Serial.read()
The previous code only printed the data received to the serial monitor, if you want to save the data in variables you will need to do some further processing. The packet you receive is split into bytes, because of this you will need to concatenate some of this data into variables.
Serial1.Read() returns an int (which for Arduino is 16 bits); however, only the first 8 bits are used. Because of this, we can copy it into a smaller data type that is only 8 bits; in this case, I will use char.![]()
For the packets that are only a byte long, this works fine:
For the packets that are 2 bytes or 4 bytes long, you will need to concatenate the data.
អ្នកអាចធ្វើវាតាមវិធីផ្សេងគ្នាជាច្រើន នៅទីនេះអ្វីដែលខ្ញុំនឹងធ្វើគឺទុកការផ្លាស់ប្តូរទិន្នន័យហើយបន្ទាប់មកឬវា។ 
ការប្រើប្រាស់កូដនេះ ប្រសិនបើ readByte1 គឺ 0x34 ហើយ readByte2 គឺ 0x12។
- (int)readByte2 // this converts the 0x12 into 0x0012.
- (int)readByte2 << 8 // this shifts the bits over by a byte making it 0x1200.
- (int)readByte2 << 8 | readByte1 // បន្ទាប់មកទទួលបាន OR'ed ដោយ 0x34 បង្កើត 0x1234 ។
វិធីមួយទៀតដើម្បីធ្វើដូច្នេះគឺដាក់តម្លៃទៅក្នុងអារេមួយ ហើយបន្ទាប់មកបំប្លែងអារេទៅជាប្រភេទដែលអ្នកចង់បាន៖

Chars are a byte long, whereas floats are 4 bytes long. Because of this, if we make an array of 4 chars with our values in, we and change the type to float.
នៅក្នុងករណីនេះ readArray គឺជាទ្រនិចទៅកាន់ char array ។ (float*)readArray ផ្នែកនេះបោះវាទៅទ្រនិចទៅអណ្តែត ហើយបន្ទាប់មក a * ត្រូវបានបន្ថែមទៅខាងមុខ ដើម្បីទទួលបានតម្លៃនៃ float ។
កំណត់ចំណាំការបំប្លែងកម្រិតខ្ពស់
- Serial.read() returns an int instead of a char because errors will return negative values. Your program should check for this.
- uint8_t and uint16_t should be used in place of char and int, respectively, as these types do not have a standard size (on my PC, int is 32 bits, whereas on the Arduino, it is 16 bits).
- The comms protocol contains byte stuffed characters (also known as control characters), this is explained in more detail in the tds0045 Premier sensor Communications protocol document. Because of this the read live data simple packet will occasionally be bigger than expected.
សំណួរគេសួរញឹកញាប់
Q: What should I do if I have an Arduino Uno with only one COM port?
A: Connect the Platinum Sensor to that port. When using the serial monitor, it will also show the transmitted hex.
ឯកសារ/ធនធាន
![]() |
DYNAMENT AN0007 Arduino ទៅ Platinum COMM [pdf] ការណែនាំអ្នកប្រើប្រាស់ AN0007 Arduino ទៅ Platinum COMM, AN0007, Arduino ទៅ Platinum COMM, ទៅ Platinum COMM, Platinum COMM |
