RB3rg / Livolo-Mod

Alternative Livolo Firmware with UART for external devices
Mozilla Public License 2.0
19 stars 8 forks source link

No function of the VL-C70x-2 #6

Open DG0JG opened 5 years ago

DG0JG commented 5 years ago

Hello I would like to modify the board VL-702x-2 with 2 relays Unfortunately, only the first channel works is it possible to help me with something to look for?

regards Stephan

RB3rg commented 5 years ago

Hi Stephen, Its not clear to me. Did you modify and just one relay works?

On Tue, Dec 18, 2018, 16:58 DG0JG <notifications@github.com wrote:

Hello I would like to modify the board VL-702x-2 with 2 relays Unfortunately, only the first channel works is it possible to help me with something to look for?

regards Stephan

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/RB3rg/Livolo-Mod/issues/6, or mute the thread https://github.com/notifications/unsubscribe-auth/ARcz9af-HiRLYzm4M8jm-3Y5XAa9RZkKks5u6VbigaJpZM4ZZEUG .

DG0JG commented 5 years ago

Hi, Yes, a relay works. But I get the second not working if I change this line to 2 channels, nothing works Channels con 1 ; Define number of LIVOLO Channels (Gang): 1 or 2

DG0JG commented 5 years ago

Hi RB3rg maybe you could help me and I can not get any further I need the switch actually as a button (KNX button) but I would do that if only both channels would work i have a 2 channel switch the first switch works in the code set to (channels con 1) I put on (channels con 2), the first switch does not work anymore the second sensor is at RC3 so I put TRISC = 00001010 (Is that correct ?) I have changed that too SW_ON var Bit[4] SW_ON[0] = 0 ; L3 (Left) ' SWITCH.0 select 1 if used, 0 if not: GANG TYPE, 4, SW_ON[1] = 1 ; L1 (right) ' SWITCH.1 select 1 if used, 0 if not: GANG TYPE, 4, 2, and 1 SW_ON[2] = 1 ; L2 (left/Center) ' SWITCH.2 select 1 if used, 0 if not: GANG TYPE, 4, 2, SW_ON[3] = 0 ; L4 ' SWITCH.3 select 1 if used, 0 if not: GANG TYPE, 4,

regrads Stephan

RB3rg commented 5 years ago

Send me a detailed picture of the circuit board. Bottom side. I'm traveling overseas this week then I'll have a look once back home.

On Fri, Dec 21, 2018, 07:55 DG0JG <notifications@github.com wrote:

Hi RB3rg maybe you could help me and I can not get any further I need the switch actually as a button (KNX button) but I would do that if only both channels would work i have a 2 channel switch the first switch works in the code set to (channels con 1) I put on (channels con 2), the first switch does not work anymore the second sensor is at RC3 so I put TRISC = 00001010 (Is that correct ?) I have changed that too SW_ON var Bit[4] SW_ON[0] = 1 ; L3 (Left) ' SWITCH.0 select 1 if used, 0 if not: GANG TYPE, 4, SW_ON[1] = 1 ; L1 (right) ' SWITCH.1 select 1 if used, 0 if not: GANG TYPE, 4, 2, and 1 SW_ON[2] = 1 ; L2 (left/Center) ' SWITCH.2 select 1 if used, 0 if not: GANG TYPE, 4, 2, SW_ON[3] = 1 ; L4 ' SWITCH.3 select 1 if used, 0 if not: GANG TYPE, 4,

regrads Stephan

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/RB3rg/Livolo-Mod/issues/6#issuecomment-449369812, or mute the thread https://github.com/notifications/unsubscribe-auth/ARcz9csicqQRjndaOCNT6Y2cLP0I0giEks5u7MwVgaJpZM4ZZEUG .

DG0JG commented 5 years ago

Hi RB3rg Here is the schematic of the Livolo 2 gang switch an picture The two pictures are not mine but it is exactly this variant So I need the function Both switches should work as buttons short press on button short pulse long press on button long pulse

Regards Stephan

04ae5d

13a5ed vl-c701x-2

RB3rg commented 5 years ago

The boards I own (American type) have different pint out from yours. If you have the touch sensor at RC3 and RC1 then TRISC=%00001010 In the relay board, find out in the ULN2003 (darlington array) which output pins drive the relays. Track down the correspondent pins in the input of ULN2003 to the PIC. in my case they are RC6 and RC7 Send a picture of the relay board.

DG0JG commented 5 years ago

Hello RB3rg, Yes I have set the register TRISC as you wrote First I try it without relay board and it works only the channel 1 As soon as I put (Channels con) on 2 nothing works anymore do I have to change something in the code somewhere else?

adrian-vlad commented 5 years ago

Hi, I had the same issue. The problem was that the code was not selecting the correct input for the second sensor and it remained blocked in the CALIBRATE loop.

The fix is to set the first bits of CMXCON0 registers to 1 like this:

CHECK_SW:
    CM1CON0.0 = 1                               ' change to correct input ch (bit 0)
    CM1CON0.1 = ch.1                                ' change to correct input ch (bit 1)
    CM2CON0.0 = 1                               ' change to correct input ch (bit 0)
    CM2CON0.1 = ch.1                                ' change to correct input ch (bit 1)

Let me know if you have any problem.

adrian-vlad commented 5 years ago

Also, you need to set the correct LED pins and set the correct SWITCH pins or adapt the code to do what you need when the sensors are touched.

I'm planning on forking this project in the next couple of days in order to fix these issues for the VL-C701X-2 version (at least for now).

DG0JG commented 5 years ago

Hi RB3rg,

Yes it works for many thanks for your support Now I have to change it that attracts the relay only as long as the sensor is pressed I need a button and no switch because I want to use this button in a KNX automation

adrian-vlad commented 5 years ago

I made a modification for that also. I checked if the lights are constantly changing when keeping the sensor pressed and it did, but only for a couple of seconds. I think this is because the SW_average will keep changing and getting equal to SW_raw at which point no change is detected. The code change to achieve this was to set debounce[ch] = 0 after Toggle LED_X.

A solution to this would be to store the initial calibration of SW_average and not change it ever. But I haven't investigated yet.

PS: I'm not RB3rg.

DG0JG commented 5 years ago

Hi Adrian,

Sorry so the name is correct :-) thanks for the tip I thought that I just change the code Turn on the relay short pause and turn off again

adrian-vlad commented 5 years ago

Yes. What I had in mind were those scenarios for setting embedded devices that tell you to hold the button pressed for X amount of seconds.

DG0JG commented 5 years ago

that's not how it works

; If SW_raw[ch] < (SW_average[ch]-10) Then ; Check if switch is touched If SW_raw[ch] < (SW_average[ch]- sense) Then ; debounce[ch] = debounce[ch] + 1 ' Debounce switch Else debounce[ch] = 0 EndIf If SW_raw[ch] > (SW_average[ch]-10) Then LED_2=0 RELAY_B = 0 endif

DG0JG commented 5 years ago

Hi Adrian, with the change it works if I press longer than 2 sec switch it off again Here is the example for channel 2 ch=2 If SW_ON[ch]=0 Then SKIP2
GoSub CHECK_SW If debounce[ch] = 1 Then Toggle LED_2 If LED_2=1 Then hSerout ["CH2:1",13,10] ' Turn light OFF comand for external device hSerout ["CH2:1",13,10] hSerout ["CH2:1",13,10] RELAY_B = 1

    Else
        hSerout ["CH2:0",13,10]         ' Turn light ON comand for external device
        hSerout ["CH2:0",13,10]
        hSerout ["CH2:0",13,10]
        RELAY_B = 0         
    EndIf

EndIf 'Serout2 TX, 84, ["RAW", DEC1 ch, ": ", DEC5 SW_raw[ch], ", AVE", DEC1 ch, ": ", DEC5 SW_average[ch], ", TIME", DEC1 ch, ": ", DEC5 sense_time[ch], ", "] ;THIS IS USED FOR TESTING SKIP2: If debounce[ch] = 0 Then LED_2=0 RELAY_B = 0 endif

DG0JG commented 5 years ago

Hi Adrian, Unfortunately my request does not work properly when the sensor is pressed or when it is not pressed Could you give me an example of how I can query the sensor? regards DG0JG

adrian-vlad commented 5 years ago

Hi, you said it worked before

with the change it works if I press longer than 2 sec switch it off again

I've made a fork where I cleaned-up all of the unnecessary code and made it work for VL-C70x-2. Also I added output pins for the switches and input pins for the leds (for external control). Have a look there. I think both repositories should be enough to get you started with your project.

Many thanks to RB3rg for making this awesome piece of code. Now I can use the switch to command some future home automation systems.

DG0JG commented 5 years ago

Hi Adrian, Have now rebuilt 6 switches and these work I had to adapt the code a bit because there are no classic relays installed in the switches There are bistable relays installed to save electricity There is an output on the PC for turning on the relay and there is an output on the PIC for switching off the relay Another challenge was that the relays are not very fast

adrian-vlad commented 5 years ago

Why would you need them very fast? Are you strobing the lights?

DG0JG commented 5 years ago

Hi Adrian, I now have 8 of the switches in use I have only one problem that the switches sometimes turn themselves For example, in the apartment, a roller shutter motor moves up or down and sometimes when it stops, the light turns on There seems to be interference on the lines which turns on the switch do you have an idea? The sensitivity to set higher than 20 does not really bring the solution

adrian-vlad commented 5 years ago

Hi, I don't know exactly what the problem is. I have made some tests with one 2gang switch and I modified the code, but I don't have it in "production".

You could try to play a bit with the sensitivity and also changing the value 2000.

Have a look at https://github.com/adrian-vlad/LivAce/blob/master/src/Livolo-Mod.pbp.

Anyway, it's hard to debug on an embedded system. It would be easier if you could hook the switch to an arduino or raspberry pi and log continuously to files. When an issue happens you could check your logs and see if any values were unexpected for the situation.

DG0JG commented 5 years ago

you mean the section ? CALIBRATE: for ch = 0 to 1 CAL_LOOP: sense_time[ch] = sense_time[ch] + 1

gosub CHECK_SW
SW_calib[ch] = SW_average[ch]

if SW_raw[ch] < 2500 then
    goto CAL_LOOP
endif

next return

adrian-vlad commented 5 years ago

Yes, CHECK_SW and CALIBRATE