#1 Re: Апаратні питання » Прошу помощи! Создание эмулятора балласта лампы проектора Epson. » 2016-01-12 23:21:39

NoName пише:

example code in message  http://forum.arduino.ua/viewtopic.php?pid=613#p613
incorrect, sorry )
its for example protocol

Finally I use case variant and I ignore that consecutive commands and it works.

#include <SoftwareSerial.h>

int data;
int rest;
int StatusLamp;
int ledPin = 13;
#define  INIT1  1
#define  INIT2  2
#define  WORK1  3
#define  WORK2  4
#define  TAG_LEN 2
#define  ARR_LEN 1


byte code[TAG_LEN];
int bytes_read = 0;

char ss[] = {0x72, 0x60};

void setup() {
  StatusLamp = INIT1;
  Serial.begin(9600, SERIAL_8E1);
  pinMode(13, OUTPUT);
}

void loop() {
}
void serialEvent() {
  while (Serial.available() > 0)
    data = Serial.read();
  //Serial.flush();
  //delay(200);
  switch ( data )
  {
    case 0x00:  Serial.write(0x00); break; //echo
    case 0x70:  Serial.write(0x70); break;  // Enable comnication
    case 0xF0:  Serial.write(0xF0); Serial.write(0x01); break;// Company ID.
    case 0xF1:  Serial.write(0xF1); Serial.write(0x16); Serial.write(0x11);; break; //Lamp driver ID
    case 0xF3:  Serial.write(0xF3); Serial.write(0x00); break;
    case 0xF2:  Serial.write(0xF3); Serial.write(0x64); break;
    case 0xF4:  Serial.write(0xF4); Serial.write(0x80); break;
    case 0xF6:  Serial.write(0xF6); Serial.write(0x02); break;
    case 0xFA:  Serial.write(0xFA); Serial.write(0x60); break;
    case 0xFB:  Serial.write(0xFB); Serial.write(0x80); break;
    //case (0x72 && 0x60):  Serial.write(0x72); Serial.write(0x60); break;
    case 0xF5:  Serial.write(0xF5); Serial.write(0x01); break;

    default  :  func_2hex_read(data); break;

  }
}

void func_2hex_read(int data) {

 

  digitalWrite(ledPin, HIGH);
}

void software_Reset()
// Restarts program from beginning but
// does not reset the peripherals and registers
{
  asm volatile ("  jmp 0");
}



Now I study how to read 2 ore more consecutive commands and compare with something.

I hope that somebody will use my information because also me I search and I found only on this forum.

#3 Re: Апаратні питання » Прошу помощи! Создание эмулятора балласта лампы проектора Epson. » 2016-01-09 23:30:36

In the bottom of my message I attach also the Saleae file.
I am novice in programming and I will correct the code.
What concern me is this:
  if (data == 0x72 && data == 60)
    Serial.write(0x72); Serial.write(0x60); //Lamp power

If you will se in raw RX/TX the mainboard send consecutive this command 72h 60h togheter. I don't know if my condition is correct.

72h is ~" Set Gain" command and 60h is min gain.

#4 Re: Апаратні питання » Прошу помощи! Создание эмулятора балласта лампы проектора Epson. » 2016-01-09 22:25:12

Good day,

I have an Optoma EP752 with OSRAM PT-VIP-03MID.
The protocol for this module it is little different then the your module.
I read the RX/TX lines and in make a little arduino code but no success.


This the code:
int data;                           //Initialise integer 'data'
int powerPin = 2;                   //Enable pin 2

void setup() {
  Serial.begin(9600, SERIAL_8E1);   //Set up serial communication
  pinMode(powerPin, OUTPUT);        //Set pin 2 to output
}

void loop() {
}



void serialEvent() {

  data = Serial.read();             //set 'data' to input received from ballast
  delay(5);

  if (data == 0x00)
    Serial.write(0x00); //echo
  if (data == 0x70)
    Serial.write(0x70); // Enable comnication
  if (data == 0xF0)
    Serial.write(0xF0); Serial.write(0x01); // Company ID.
  if (data == 0xF1)
    Serial.write(0xF1); Serial.write(0x16); Serial.write(0x11); //Lamp driver ID
  if (data == 0xF3)
    Serial.write(0xF3); Serial.write(0x00); //Selected Waveform
  if (data == 0xF2)
    Serial.write(0xF2); Serial.write(0x64); //Waveform ID
  if (data == 0xF4)
    Serial.write(0xF4); Serial.write(0x80); //Act Gain
  if (data == 0xF6)
    Serial.write(0xF6); Serial.write(0x02); //Waveform Count
  if (data == 0xFA)
    Serial.write(0xFA); Serial.write(0x60);//Min Gain
  if (data == 0xFB)
    Serial.write(0xFB); Serial.write(0x80); //Max Gain
  if (data == 0x72 && data == 60)
    Serial.write(0x72); Serial.write(0x60); //Lamp power
  if (data == 0xF5)
    Serial.write(0xF5); Serial.write(0x01);
  //default  :  func_unique_request(data); break;



}


https://www.dropbox.com/s/b0c5paibctzqn … 1.ino?dl=0
https://www.dropbox.com/s/jl9be4j7fpbpj … cdata?dl=0

Підвал форуму