Идея публикации этой статьи возникла после долгих поисков в инете нужной информации о программировании переносных радиостанций MotoTurdo, в данном случае Motorola DP4600. Родной кабель для программирования Motorola DP4600 стоит порядка 100$. Зачем тратить такие бабки? схема проста для "праворуких" и весь набор элементов обойдется не более чем в 200 руб, тем более в стране импортозамещение.
На втором рисунке представлена схема кабеля, она довольна проста. В качестве идентификации для радиостанции моторола используется 1-wire чип DS2433 , который я выпаял в старом литиевом аккумуляторе от DP4600. Чип естественно для шнурка нужно прошить по новомую. Я использовал программатор собранный на ардуино, как показано на первом рисунке.
НЕТ чипа DS2433 - не беда. Его можно симулировать на ардуинке как на рисунке 3, скетч будет ниже.
Главное в чипе не ROM ключ, а содержимое EEPROM памяти.
Итак, прошиваем ds2433 согласно следующего скетча
_____________________________________________________________________________________________________________________________
/*
DS2433 EEPROM
EEPROM 512byte(8bit*512byte) teble16(32byte*16table)
LASERE_ROM 8byte (8-Bit Family Code + 48-Bit Serial Number + 8-Bit CRC Tester)
Scratchpad 32byte(8bit*32byte)
*/
#include <OneWire.h> //библиотека здесь https://github.com/ntruchsess/arduino-OneWire
OneWire ds(10); // on pin 10
int i,p,r;
byte data[512];
byte addr[8];
byte resetdata[8][16]={
{0x55,0x53,0x42,0x44,0x01,0xFF,0x02,0xFF,0x00,0x0C,0x00,0x44,0x0A,0x1C,0x00,0x00},
{0x00,0x01,0x50,0x4D,0x4B,0x4E,0x34,0x30,0x31,0x32,0x20,0x20,0x20,0x20,0x20,0x20},
{0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF},
{0x00,0xFF,0x50,0x20,0x55,0x53,0x42,0x20,0x44,0x65,0x76,0x20,0x43,0x61,0x62,0x6C},
{0x65,0x00,0x39,0x2D,0x0B,0x09,0x03,0x00,0x01,0x01,0x00,0x00,0xFF,0xFF,0x05,0x09},
{0x00,0x00,0x00,0x00,0xED,0xCF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; //128byte
void setup(void) {
delay(1000);
Serial.begin(9600);
}
void loop(void) {
if ( !ds.search(addr)) {
Serial.println("Can not find the device");
ds.reset_search();
delay(5000);
return;
}
if ( addr[0] == 0x23) {
Serial.println("this Device is DS2433 family device");
}
else{
Serial.println("this Device is not a DS2433 family device");
//return;
}
Serial.print("device address = ");
for( i = 0; i < 8; i++) {
Serial.print(addr[i], HEX);
Serial.print(" ");
}
if ( OneWire::crc8( addr, 7) != addr[7]) {
Serial.println("CRC is not valid!");
return;
}
Serial.println("");
Serial.println("");
delay(1000);
read_eeprom();
Serial.println("Сейчас пауза 60 секунд. Если хотите прошить под дата кабель, то ждите процесса программироания чипа DS2433. Если нет, то выключаем ардуинку от питания");
delay(60000);
write_EEPROM();
}
/* READ_EEPROM */
void read_eeprom(){
ds.reset();
ds.write(0xcc); //skip command
ds.write(0xf0); //eeprom read command
ds.write(0x00); //adrees
ds.write(0x00); //adrees
Serial.println("EEPROM DATA (512byte) =(");
for (int i = 0; i <= 511; i++) {
data[i] = ds.read();
}
for (int i = 0; i <= 511; i++) {
if(data[i]<0x10)Serial.print(0);
Serial.print(data[i], HEX);
Serial.print(" ");
if(i%16==15){
Serial.println("");
}
}
Serial.println(")HEX");
Serial.println(" ");
}
void flashWrite(void) {
// Write to the Flash
// Allocate and clear some ram to buffer into
uint8_t newFlash[512];
memset(newFlash, 0, sizeof(newFlash));
//Fill it with data
Serial.readBytes((char*) newFlash, sizeof(newFlash));
// Each loop is a 4 byte chunk
uint8_t bytesPerWrite = 8;
for( uint16_t offset = 0; offset < (512/bytesPerWrite); offset++)
{
uint16_t memAddress = offset * bytesPerWrite;
// Fail if presense fails
if (!ds.reset()) {
Serial.write("fp0");
return;
}
ds.write(0xCC); // Skip ROM
ds.write(0x0F); // Write Scratch Pad
// Compute the two byte address
uint8_t a1 = (uint8_t) memAddress;
uint8_t a2 = (uint8_t) (memAddress >> 8);
// Write the offset bytes . . . why in this order?!?!?
ds.write(a1);
ds.write(a2);
// Fill the 4 byte scratch pad
for (uint8_t i = 0; i < bytesPerWrite; i++)
ds.write(newFlash[memAddress + i]);
// Fail if presense fails
if (!ds.reset()) {
Serial.write("fp1");
return;
}
ds.write(0xCC); // Skip ROM
ds.write(0xAA); // Read scratch pad
// Confirm offset gets mirrored back, otherwise fail
if(ds.read() != a1) {
Serial.write("fo1");
return;
}
if(ds.read() != a2) {
Serial.write("fo2");
return;
}\
// Read the confirmation byte, store it
uint8_t eaDS = ds.read();
// Check the scratchpad contents
for (int i = 0; i < bytesPerWrite; i++)
{
uint8_t verifyByte = ds.read();
if ( verifyByte != newFlash[(offset*bytesPerWrite + i)])
{
Serial.println("fvv");
return;
}
}
// Fail if presense fails
if (!ds.reset()) {
Serial.write("fp2");
return;
}
// Commit the 8 bytes above
ds.write(0xCC); // Skip ROM
ds.write(0x55); // Copy scratchpad
// Confirmation bytes
ds.write(a1);
ds.write(a2);
ds.write(eaDS, 1); // Pullup!
delay(5); // Wait 5 ms per spec.
}
Serial.println("t");
}
/* WRITE_EEPROM */
void write_EEPROM(){
flashWrite();//чистим память
delay(1000);
//записываем в память массив
for(byte abbress=0x00;abbress<=0x70;abbress=abbress+0x10){
ds.reset();
ds.write(0xcc); //skip command
ds.write(0x0f); //scratchpad_write
ds.write(abbress);//write address TA1
ds.write(0x00); //write address TA2
for ( i = 0; i <= 15; i++){
ds.write(resetdata[abbress/16][i]);
}
ds.reset();
ds.write(0xcc); //skip command
ds.write(0xaa); //scratchpad_read
byte T1=ds.read();
byte T2=ds.read();
byte E_S=ds.read();
Serial.print("TA1=");
Serial.print(T1,HEX);
Serial.print(" TA2=");
Serial.print(T2,HEX);
Serial.print(" E/S=");
Serial.println(E_S,HEX);
Serial.println("read scratchpad deta=");
for ( i = 0; i <= 15; i++){
data[i] = ds.read();
}
for ( i = 0; i <= 15; i++) {
Serial.print(data[i], HEX);
Serial.print(" ");
if(i%16==15){
Serial.println("");
}
}
delay(1000);
ds.reset();
ds.write(0xcc); //skip command
ds.write(0x55); //scratchpad_copy
ds.write(abbress);//write address TA1
ds.write(0x00); //write address TA2
ds.write(E_S); //write address e/s
delay(5);
}
}________________________________________________________________________________________________________________________________________
Теперь обещанный скетч для симуляции ds2433 с кодом для Arduino Nano
_________________________________________________________________________________________________________________________________________
/*
* Example-Code that emulates a DS2433 4096 bits EEPROM
*
* Tested with
* - DS9490R-Master, atmega328@16MHz and teensy3.2@96MHz as Slave
*/
#include "OneWireHub.h"
#include "DS2433.h"
constexpr uint8_t pin_onewire { 10 };
auto hub = OneWireHub(pin_onewire);
//23 AB 69 FA 00 00 00 84 это был родной rom от родного кабеля
auto ds2433 = DS2433(DS2433::family_code, 0xAB, 0x69, 0xFA, 0x00, 0x00, 0x00);
//далее содержимое памяти ds2433 от родного кабеля
constexpr uint8_t memDUMP[] =
{0x55,0x53,0x42,0x44,0x01,0xFF,0x02,0xFF,0x00,0x0C,0x00,0x44,0x0A,0x1C,0x00,0x00,
0x00,0x01,0x50,0x4D,0x4B,0x4E,0x34,0x30,0x31,0x32,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
0x00,0xFF,0x50,0x20,0x55,0x53,0x42,0x20,0x44,0x65,0x76,0x20,0x43,0x61,0x62,0x6C,
0x65,0x00,0x39,0x2D,0x0B,0x09,0x03,0x00,0x01,0x01,0x00,0x00,0xFF,0xFF,0x05,0x09,
0x00,0x00,0x00,0x00,0xED,0xCF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
void setup()
{
Serial.begin(115200);
Serial.println("OneWire-Hub DS2433");
hub.attach(ds2433);
ds2433.writeMemory(memDUMP, sizeof(memDUMP), 0);
Serial.println("config done");
}
void loop()
{
// following function must be called periodically
hub.poll();
}
________________________________________________________________________________________
Я не использовал резистор подтяжки 4,7Ком на контакт 1-wire т.к. у меня работает и без него. При успешном сопряжении кабеля с радиостанцией, на мотороле появляется надпись на экране impres(tm) с характерном писком. В диспетчере устройсв на компьютере появляется новое сетевое устройство mototrbo radio. Для настроек функций радиостанции использую программу MOTOTRBO CPS версия 10.8 (сборка 590).
Желаю удачи! 73
Добавить комментарий