Dear all,
I met an issue when running UNO, it can control the LED driver IC, but after a few minutes, the program stops, verytime this will happen either after recycling the power or re-programming.
can you give me some hint? many thanks.
................................................
void loop() {
//read Vdim and tranfer to digital value, Vdim-->output level,0x10 with 0-100
//UNO: 5 volts / 1024 units or, 0.0049 volts (4.9 mV) per unit.
int Vdim=analogRead(A0); //analog reading (which goes from 0 - 1023)
byte Vdim100=Vdim*(100.0/1023.0); //range:0-100
byte L1=Vdim100;
delay(2);
byte OutL=(L1+L0)/2; //byte L0=0 is defined earlier
delay(2);
byte OutLevel = Wire.read();
Serial.print("OutLevel, 0x10= ");Serial.println(OutLevel); // if Slave not connected, value is 255
Serial.print("RTN= ");Serial.println(RTN);
Interesting problem but I cannot follow it. Please read the forum gujdelines and post your code according them using code tags. Post all of the code.
Guidelines: How to get the best out of this forum Also if there are hardware devices include links to there technical information and an annotated schematic showing how it is wired, be sure to include all power, grounds and power sources.
#include <Wire.h>
#define CHIP_ADDRESS 0x38 //0x38
#define REGISTER_ADDRESS 0x10 //0x10 bit7-Control type,0-standalone,1-I2C; 0x10-bit6:0,Output level=0~100/99
#define REGISTER_DP_ADDRESS 0x76 // Dimmer Phase: >88, no dimmer; <85, w/ dimmer
byte L0=0;
byte val=0;
void setup() {
Wire.begin(); // join i2c bus as a controller or a peripheral(address optional for master),initializes the Wire library
//address: the 7-bit slave address (optional); if not specified, join the bus as a controller device.
//Wire.setClock(100000);//100KHz baseline,75kHz/10kHz can run, but also stops.
Serial.begin(9600); // start serial for output
/// wakeup
Wire.beginTransmission(CHIP_ADDRESS);
Wire.endTransmission();
delay(2); //ms
/// Passkey
Wire.beginTransmission(CHIP_ADDRESS);
Wire.write(0x42); //0x42
Wire.write(0xA7); //
Wire.endTransmission();
delay(2);
Wire.beginTransmission(CHIP_ADDRESS);
Wire.write(0x42); //0x42
Wire.write(0x65); //
Wire.endTransmission();
delay(2);
Wire.beginTransmission(CHIP_ADDRESS);
Wire.write(0x42); //0x42
Wire.write(0x3F); //
Wire.endTransmission();
delay(2);
/// 0x35=91
Wire.beginTransmission(CHIP_ADDRESS);
Wire.write(0x35); //
Wire.write(0x91); //
Wire.endTransmission();
delay(2);
/// 0x19=80
Wire.beginTransmission(CHIP_ADDRESS);
Wire.write(0x19); //
Wire.write(0x80); //
Wire.endTransmission();
delay(2);
/// 0x52=00
Wire.beginTransmission(CHIP_ADDRESS);
Wire.write(0x52); //
Wire.write(0x00); //
Wire.endTransmission();
delay(2);
/// 0x3A=70
Wire.beginTransmission(CHIP_ADDRESS);
Wire.write(0x3A); //
Wire.write(0x70); //
Wire.endTransmission();
delay(2);
/// No dimmer:Isnk set,0x3B=40
Wire.beginTransmission(CHIP_ADDRESS);
Wire.write(0x3B); //
Wire.write(0x40); //
Wire.endTransmission();
delay(2);
/// No dimmer:Isnk set, 0x3D=0C
Wire.beginTransmission(CHIP_ADDRESS);
Wire.write(0x3D); //
Wire.write(0x0C); //
Wire.endTransmission();
delay(2);
/// LightOutput: 0x10=64(=100,dec), next 0xFF
val=0x00|0b10000000; //val=0x64|0b10000000, new*@12.12
Serial.print("val= ");Serial.println(val, BIN);
Wire.beginTransmission(CHIP_ADDRESS);
Wire.write(0x10); //
Wire.write(val); //
Wire.endTransmission();
delay(2);
//Serial.println(b, DEC); // print in decimal, same as above
//Serial.println(b, BIN); // print in binary
//Serial.println(b, HEX); // print in hexadecimal
}
void loop() {
//read Vdim and tranfer to digital value, Vdim-->output level,0x10 with 0-100
//UNO: 5 volts / 1024 units or, 0.0049 volts (4.9 mV) per unit.
int Vdim=analogRead(A0); //analog reading (which goes from 0 - 1023)
byte Vdim100=Vdim*(100.0/1023.0); //range:0-100
byte L1=Vdim100;
delay(2);
///*
byte OutL=(L1+L0)/2;
// Serial.print("OutL= ");Serial.println(OutL);
// Serial.print("L1= ");Serial.println(L1);
// Serial.print("L0= ");Serial.println(L0);
delay(2);
byte OutL1=L1|0b10000000;//add bit7=1
// Serial.print("OutL1=");Serial.println(OutL1, BIN);
delay(2);
/// Only Vdim has variation(>=1%), change value of dimming register 0x10
if (abs(L1-L0)>=1)
{
//// dimming
Wire.beginTransmission(CHIP_ADDRESS);
Wire.write(REGISTER_ADDRESS); //0x10
Wire.write(OutL1); // byte=decimal(*)
Wire.endTransmission();
delay(5);
}
// else {}
//// Serial.print content of Register
Wire.beginTransmission(CHIP_ADDRESS);
Wire.write(REGISTER_ADDRESS); //0x10-outputlevel, 0x76-DimPhaseAngle,
byte RTN=Wire.endTransmission();//change to false,read ReTurN,12.20
Wire.requestFrom(CHIP_ADDRESS,1); //change to false,NG--12.20
delay(5);
//judge if it is a sucessful read
// while(Wire.available()) { //new 12.20
byte OutLevel = Wire.read();
Serial.print("OutLevel, 0x10= ");Serial.println(OutLevel); // if Slave not connected, value is 255
Serial.print("RTN= ");Serial.println(RTN);
// Serial.println(OutLevel,BIN);//Serial.println(OutLevelx,HEX);
// Serial.println("");
// }
L0=L1;
delay(250);
}
Sorry, I just started to use the forum, not so familiar with the rule. I am not sure if it is the right way to insert code.
attach some slave IC information,
Thanks@GolamMostafa,
I tried, but seems the problem still occurs.
I upload the I2C signal pictures before the programing stops for 3 cases, it seems I2C signal is abnormal. pls. note the above timing is abnormal while the below one in each picture is normal.
I want to dim or control the brightness of the LEDs through I2C by the analog voltage seen at UNO A0. UNO programing is used as a translation from analog voltage to the dimming or brightness level(0...100 for register 0x10 in iW3690) via I2C.
1. How much AC voltage across L and N terminals? 2. How much DC voltage across + and - terminals. 3. Is 3.3V coming from Host Controller (the UNO) or being produced by R3 voltage regulator?
4. Are you controlling the operation of U1 (IW3690) to regulate DC voltage across + and - terminals from Host Controller over I2C Bus?
5. What is function/need of U2 (CR1510)? 6. Have you built the sub-system of Fig-1? If yes, is it on the Breadboard or on the PCB?
7. Please, post/attch the detailed data sheets of the device.
I try to control the operation of U1 (IW3690) to regulate DC current across + and - terminals(ie. LED current) from Host Controller over I2C Bus. if I send different output value to register(0x10), output current level of iw3690, the output LED current is hence changed.
U2 is high voltage buck, generating 5V from rectified AC mains.
no more sub-system except the UNO board with analog voltage input.
I tried, but new user has no right to upload document, so pls. tell me if you need more information.
I have a brief 7-page specification of the chip; but, I need full data sheets part of which I see in your post #3. You can post the link of the data sheets.
I am afraid the information and introduction in the spec./datasheet is not so detailed, esp. for the firmware sequence/timing and overall registers. I got some information from a demo board and mimic the sequence of writing the registers to get the start-up of iw3690.
I can mail you the datasheet if you can leave email here, thanks.
Yes, it is a non-isolated solution, but it shall work when UNO GND is connected primary side GND of iw3690 driver board.
sometimes, I powered UNO with 12V isolated adaptor power via the black connector on the UNO, and let UNO run alone. but if I2C logic waveforms are taken, I remove 12V adaptor and connect cable btw. notebook USB port and UNO series port(silver color connector on UNO).
When in running, I won't touch any of the device as it is non-isolated system.
I worked for power/SSL driver for more than 10 year.
My email is sent to your personal message box where you can send the data sheets of IW3690.
It looks like that there is a temperature sensor inside the IW3690 device. Can you read the temperature to verify that the UNO has access to the device?
isolated transformer(①) is put btw. grid and mains input iw3690 driver, but just for isolated purpose, as the voltage on the driver is quite high, so it is still not safe for manual touch, sufficient carefulness shall be paid anyway. like using insulated plastic screwdriver to change the analog voltage on Arduino A0 pin.
300V of the circuit you post is from "HV node"(②) of the LED driver iw3690, HV node is more accurate, value 300V is around 230V*1.414.