Noritake-itron plus CAN

arduino, teensy, atmega, pic a jine (software, hardware)
Odpovědět
lubos
Sponzor fora
Příspěvky: 5088
Registrován: 2. 5. 2007, 3:47
Bydliště: Praha

23. 12. 2014, 8:03

Snažim se rozchodit lcd od Noritake s Can komunikací.
Už to nějak chodí ale někde tam je zásadní problém který nevidím.
Po připojení se to chová dost náhodně, někdy to zobrazí jen napětí, jindy jinou hodnotu . Někdy nic. Navíc to zobrazí jen první načtený paket pak už nic.
Už jsem z toho trochu zoufalej.
Upozornuju že nejsem programátor a maximálně bastlím něco v arduinu. Ještě můžu přihodit video jak se to chová pokud by měl někdo chut se na to podívat.

Kód: Vybrat vše

// Example code for displaying parameters received via CANbus from a MGM Compro ESC
//
// Settings :-
// 125K
// 11 bit address
// Text mode
//
// Receive packets processed :-
//
// 0x001 aa bb cc dd
// V = (aa + 256 x bb) / 57.45
// I = (cc + 256 x dd) / 10
//
// 0x002 xx xx xx xx aa
// T = aa
//
// 0x003 xx xx xx xx aa bb
// Warn(bit 0) = (aa + 256 x bb)
//
// Requires TFT firmware version 00.49.55 or later

LIB(fnt, "sdhc/asc_32.fnt");
LIB(fnt2, "sdhc/asc_24.fnt");

STYLE(ts, text)  { font = fnt; col = white; }
STYLE(tsw, text) { font = fnt2; col = red; }

VAR(tempL, 0, U8);
VAR(tempH, 0, U8);
VAR(tempstr, "", TXT);
VAR(rxpacket, "", TXT);
VAR(voltage, 0, FLT1);
VAR(current, 0, FLT1);
VAR(temperature, 0, U8);
VAR(warning, 0, U16);
VAR(warning_flag, 0, U16);

SETUP(AS1)
{
  baud = 38400;
  parity = N;
  data = 8;
  stop = 1;
  rxi = Y;
  txi = Y;
  flow = H;
  encode = sd;
  proc = CR;
  procdel = Y;
}

INT(i, AS1RXC, rx);

PAGE(p, DSP_)
{
  // Voltage
  TEXT(tv, "0V", ts, 240, 60);
  
  // Current
  TEXT(ti, "0A", ts, 240, 130);
  
  // Temp
  TEXT(tt, "0\\b0C", ts, 240, 200);
  
  // Warn
  TEXT(tw, "* Undervoltage Warning *", tsw, 240, 250); HIDE(tw);
 
  
  // Debug
  TEXT(td, "", ts, 240, 256);
  
}

FUNC(setup)
{
   
  LOAD(AS1, "C\\0D"); 
  LOAD(AS1, "\\1BCfY");
  WAIT(1500);
 LOAD(AS1, "C\\0D"); 
 WAIT(1000);
  LOAD(AS1, "B3\\0D");
  wait(1000);
 LOAD(AS1, "O\\0D");
}

// CAN packet received
// determine address and process data accordingly
FUNC(rx)
{
  LOAD(rxpacket, AS1);
  TEXT(td, rxpacket);;
  CALC(tempstr, rxpacket, 1, 3, "BCOPY");
  if(tempstr=="001"?fvoltage_current);
  if(tempstr=="002"?ftemp);
  if(tempstr=="003"?fwarning);
}

FUNC(fvoltage_current)
{
  CALC(tempstr, rxpacket, 5, 2, "BCOPY");
  CALC(tempL, tempstr, "HEX8A", "BCNV");
  CALC(tempstr, rxpacket, 7, 2, "BCOPY");
  CALC(tempH, tempstr, "HEX8A", "BCNV");
  CALC(voltage, tempH, 256, tempL, "*+");
  CALC(voltage, voltage, 57.45, "/");
  LOAD(tempstr, voltage, "V");
  TEXT(tv, tempstr);
  CALC(tempstr, rxpacket, 9, 2, "BCOPY");
  CALC(tempL, tempstr, "HEX8A", "BCNV");
  CALC(tempstr, rxpacket, 11, 2, "BCOPY");
  CALC(tempH, tempstr, "HEX8A", "BCNV");
  CALC(current, tempH, 256, tempL, "*+");
  CALC(current, current, 10, "/");
  LOAD(tempstr, current, "A");
  TEXT(ti, tempstr);;
}

FUNC(ftemp)
{
  CALC(tempstr, rxpacket, 13, 2, "BCOPY");
  CALC(temperature, tempstr, "HEX8A", "BCNV");
  LOAD(tempstr, temperature, "\\b0C");
  TEXT(tt, tempstr);;
}

FUNC(fwarning)
{
  CALC(tempstr, rxpacket, 13, 2, "BCOPY");
  CALC(tempL, tempstr, "HEX8A", "BCNV");
  CALC(tempstr, rxpacket, 15, 2, "BCOPY");
  CALC(tempH, tempstr, "HEX8A", "BCNV");
  CALC(warning, tempH, 256, tempL, "*+");
  CALC(warning_flag, warning, 1, "&");
  IF(warning_flag==1?[SHOW(tw);]:[HIDE(tw);]);;
}

RUN(setup);

SHOW(p);
XpertMill, Gravos, Ninos, Galaad
IQ156
-1500Kč, -520Kč, -1čokoláda, - 28000Kč
www.freeair.cz www.rotexelectric.eu www.retrofitcnc.cz
Odpovědět

Zpět na „MCU“