Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 19:41 10 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Micromite controlled Smart -Home System

Author Message
RonnS
Senior Member

Joined: 16/07/2015
Location: Germany
Posts: 120
Posted: 02:17pm 14 Feb 2017
Copy link to clipboard 
Print this post

Hurraaa I finally got it to work (first steps)

this is the begin of my or our Micromite controlled "Smart Home-System"
My vision is a Micromite to control all my home radiator valves, switching and diming Lights and others

first ab very big thankyou to Peter Mather for his BitBang-CSub

the details:
i choose the 433,92 Mhz System there are cheap transmitters and actuators available

needed parts:
1) a SMARTWARES Radiator Valve
http://www.homewizard.co.uk/smartwares-wireless-radiator-valve.html
2) a 433,92 Mhz Transmitter
http://www.watterott.com/de/RF-Link-Sender-434MHz
3)a 433,92 Mhz Reciver
http://www.watterott.com/de/RF-Link-2400bps-Empfaenger-434MHz
4) a cheap Generic USB Saleae Logic Analyzer, China clone for about 6 dollars
and as software for windows : "pulseview"
https://sigrok.org/wiki/PulseView

so you can start it

the Smartwares Valves use as Transmitting Protocol a Protocol named "Arctech-switch"
You can find more details here: https://wiki.pilight.org/doku.php/arctech_switch_v7_0

see this site for fourther informations

many hours after work i used to read this and messure Pulse , test it and do this again till it works

With the following test program I reached on and off the valves
'puls generator from P.Mather
option autorun on
cpu 48
Option explicit
option default NONE
setpin 18,DOUT
pin(18)=1
Dim Float StartS(27)=(270, 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, 270 , 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, 380, 155, 325)
dim float lengthsZ(41)=(245, 2475, 352, 195, 337, 1200, 345, 1200, 345, 229, 314, 225, 314, 1200, 318, 226, 314, 1200, 314, 228, 307, 1334, 320, 235, 304, 1247, 304, 245, 302, 1252, 302, 1243, 305, 244, 305, 250, 300, 1276, 278, 239, 304, 660)'lst Val reduced from 1200
dim float lengthsA(39)=(330, 200, 330, 1200, 330, 214, 330, 1224, 330, 1211, 330, 212, 330, 1200, 330, 214, 330, 1212, 330, 220, 330, 1220, 330, 220, 330, 220, 330, 1230, 330, 220, 330, 1220, 330, 220, 330, 1230, 330, 220, 330, 660)
dim float lengthsB(27)=(330, 300, 330, 1232, 320, 300, 330, 1233, 320, 300, 320, 1233, 320, 300, 320, 1220, 330, 300, 330, 1225, 330, 300, 330, 1220, 330, 300, 330, 660)
dim float lengthsC_ON(21) =(330, 1220, 330, 300, 330, 300, 330, 1220, 320, 300, 320, 1200, 340, 207, 340, 1213, 340, 1208, 340, 206, 340, 10600)
dim float lengthsC_OFF(21)=(330, 300, 330, 1220, 330, 300, 330, 1220, 320, 300, 320, 1200, 340, 207, 340, 1213, 340, 1208, 340, 206, 340, 10600)
'array of bit lengths in usec
do

pause 500
pin(18)=1
bitbanger(18,28,StartS())
pin(18)=0
bitbanger(18,42,lengthsZ())
rem pin(18)=0
bitbanger(18,40,lengthsA())
pin(18)=0
bitbanger(18,28,lengthsB())
pin(18)=0
bitbanger(18,22,lengthsC_ON())
pin(18)=0

bitbanger(18,42,lengthsZ())
rem pin(18)=0
bitbanger(18,40,lengthsA())
pin(18)=0
bitbanger(18,28,lengthsB())
pin(18)=0
bitbanger(18,22,lengthsC_ON())
rem pin(18)= 0

bitbanger(18,42,lengthsZ())
rem pin(18)=0
bitbanger(18,40,lengthsA())
pin(18)=0
bitbanger(18,28,lengthsB())
pin(18)=0
bitbanger(18,22,lengthsC_ON())
rem pin(18)=0

bitbanger(18,42,lengthsZ())
rem pin(18)=0
bitbanger(18,40,lengthsA())
pin(18)=0
bitbanger(18,28,lengthsB())
pin(18)=0
bitbanger(18,22,lengthsC_ON())
rem pin(18)=0

'bitbanger(18,42,lengthsZ()) 'DEBUG
'rem pin(18)=0 'DEBUG
'bitbanger(18,40,lengthsA()) 'DEBUG
'pin(18)=0 'DEBUG
'bitbanger(18,40,lengthsB()) 'DEBUG
'pin(18)=0 'DEBUG
'bitbanger(18,10,lengthsC()) 'DEBUG
'rem pin(18)=0 'DEBUG

'bitbanger(18,42,lengthsZ()) 'DEBUG
'rem pin(18)=0 'DEBUG
'bitbanger(18,40,lengthsA()) 'DEBUG
'pin(18)=0 'DEBUG
'bitbanger(18,40,lengthsB()) 'DEBUG
'pin(18)=0 'DEBUG
'bitbanger(18,10,lengthsC()) 'DEBUG
'rem pin(18)=0 'DEBUG

'bitbanger(18,42,lengthsZ()) 'DEBUG
'rem pin(18)=0 'DEBUG
'bitbanger(18,40,lengthsA()) 'DEBUG
'pin(18)=0 'DEBUG
'bitbanger(18,40,lengthsB()) 'DEBUG
'pin(18)=0 'DEBUG
'bitbanger(18,10,lengthsC()) 'DEBUG
pin(18)=0
loop
end

CSub bitbanger 'pin number, number of bits, floating point array of bit lengths in usec
00000000
27BDFFC0 AFBF003C AFBE0038 AFB70034 AFB60030 AFB5002C AFB30024 AFB20020
AFB1001C AFB00018 AFB40028 3C109D00 8E030000 00808821 8E020080 8C640000
00A09021 00002821 00C0B021 0040F809 8E140064 00409821 8E02009C 3C0449F4
0040F809 24842400 00402821 0280F809 02602021 0040B821 8E240000 8E020024
24050007 0040F809 241E0001 AFA20010 8E020028 0040F809 8E240000 8E520000
8E030040 005EF004 0060F809 00122080 AFA20014 12400013 0040A821 0000A021
00008821 3C139D00 0014A080 02D41821 8C640000 8E620058 8E70007C 0040F809
02E02821 26310001 0200F809 00402021 02B4A021 0232182B AE820000 1460FFF2
0220A021 8FA30014 3C040008 8C620000 2442FFFD AC620000 3C03BF88 AC641064
3C03BF88 00001021 AC601068 40824800 8FA50014 8FA30010 2652FFFF AC7E0000
8CA40000 00442021 40024800 0044182B 1460FFFD 00000000 1640FFF6 24A50004
8FBF003C 3C020008 3C03BF88 AC621064 3C03BF88 8FBE0038 8FB70034 8FB60030
8FB5002C 8FB40028 8FB30024 8FB20020 8FB1001C 8FB00018 AC621068 03E00008
27BD0040
End CSub



thank you for watching i hope this is an interesting projekt fon many others

my home control with a micromite


my next questions :
is it possible to send these sequences at once?
send it as as binäry code as an example "00000000011110001001000000101111" ?
to make a automatically reading of this pulses . and so on ?

the first step i have done please help me for further development

i think that others are interesting in this too

Ronald (RonnS)

regards vvRon
 
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1098
Posted: 04:27pm 14 Feb 2017
Copy link to clipboard 
Print this post

@ronns

Ineresting project Ron - can you explain further what you are doing with the bitbang sequences please?
Doug.

... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!
 
RonnS
Senior Member

Joined: 16/07/2015
Location: Germany
Posts: 120
Posted: 10:19pm 14 Feb 2017
Copy link to clipboard 
Print this post

hello Doug,

in this case you have to send very short pulses.
a normally basic command alone without doing something needs in my case 600 microseconds

you have to send the following Puls pattern (high and low) as an example

370, 2445,
330, 220, 330, 1220,
330, 1173, 330, 220,
370, 220, 370, 1186,
370, 220, 370, 1149,
349, 220, 343, 1205,
340, 220, 340, 1200,
340, 220, 340, 1200,
330, 1200, 330, 220,
330, 220, 330, 1215,
330, 220, 340, 500
330, 200, 330, 1200,
330, 214, 330, 1224,
330, 1211, 330, 212,
330, 1200, 330, 214,
330, 1212, 330, 220,
330, 1220, 330, 220,
330, 220, 330, 1230,
330, 220, 330, 1220,
330, 220, 330, 1230,
330, 220, 330, 500
330, 300, 330, 1232,
320, 300, 330, 1233,
320, 300, 320, 1233,
320, 300, 320, 1220,
330, 300, 330, 1225,
330, 300, 330, 1220,
330, 300, 330, 1220,
330, 1220, 330, 300,
330, 300, 330, 1220,
320, 300, 320, 500
260, 300, 260, 1220,
260, 1220, 260, 300,

260, 10600


This is only possible with a Cfunction

a problem is that the line lengh is limited so i could send with Peters code only 42 bits at once

could we find another way ?

RonEdited by RonnS 2017-02-16
 
RonnS
Senior Member

Joined: 16/07/2015
Location: Germany
Posts: 120
Posted: 12:58am 24 Feb 2017
Copy link to clipboard 
Print this post

hello..the news:

now I can control these two units



and i took deeper look at the Arctech protocol so i found thats only one line of code needed to change the Status and the unit-number

i have made a little usable code ( Micromite 170 28 Pin) under use of Peter Mathers bitbang CSub -
That makes everything a bit clearer and I commented the bits to be changed

'puls generator from P.Mather
option autorun on
cpu 48
Option explicit
option default NONE
dim integer repeater
dim string comand
setpin 18,DOUT
pin(18)=1
Dim Float StartS(27)=(270, 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, 270 , 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, 380, 155, 325)
dim float UnitNbrV(41)=(245, 2475, 352, 195, 337, 1200, 345, 1200, 345, 229, 314, 225, 314, 1200, 318, 226, 314, 1200, 314, 228, 307, 1334, 320, 235, 304, 1247, 304, 245, 302, 1252, 302, 1243, 305, 244, 305, 250, 300, 1276, 278, 239, 304, 660)'lst Val reduced from 1200
dim float lengthsA(39)=(330, 200, 330, 1200, 330, 214, 330, 1224, 330, 1211, 330, 212, 330, 1200, 330, 214, 330, 1212, 330, 220, 330, 1220, 330, 220, 330, 220, 330, 1230, 330, 220, 330, 1220, 330, 220, 330, 1230, 330, 220, 330, 660)
dim float lengthsB(27)=(330, 300, 330, 1232, 320, 300, 330, 1233, 320, 300, 320, 1233, 320, 300, 320, 1220, 330, 300, 330, 1225, 330, 300, 330, 1220, 330, 300, 330, 660)
dim float UnitA_ON(21) =(330, 1220, 330, 300, 330, 300, 330, 1220, 320, 300, 320, 1200, 340, 207, 340, 1213, 340, 1208, 340, 206, 340, 10600)
dim float UnitA_OFF(21)=(330, 300, 330, 1220, 330, 300, 330, 1220, 320, 300, 320, 1200, 340, 207, 340, 1213, 340, 1208, 340, 206, 340, 10600)
dim float UnitD_ON(21) =(330, 1220, 330, 300, 330, 300, 330, 1220, 340, 1208, 300, 300, 240, 207, 300, 1213, 300, 240, 340, 1200, 340, 10600)
dim float UnitD_OFF(21)=(330, 300, 330, 1220, 330, 300, 330, 1220, 340, 1208, 300, 300, 240, 200, 300, 1213, 300, 240, 340, 1213, 340, 10600)
' < ON/OFF > < 0 > < 1 > < 0 > < 0 >< footer >
' < UNIT D= 4 >< footer >
'array of bit lengths in usec
do
input comand
if comand = "a" then Pause 500:Valve1_ON:end if
if comand = "aa" then Pause 500:Valve1_OFF:end if
if comand = "d" then :ValveD_ON:end if
if comand = "dd" then :ValveD_OFF:end if
loop

Sub ValveD_ON
pin(18)=0
bitbanger(18,28,StartS())
for repeater =1 to 12
pin(18)=0
bitbanger(18,42,UnitNbrV())
bitbanger(18,40,lengthsA())
pin(18)=0
bitbanger(18,28,lengthsB())
pin(18)=0
bitbanger(18,22,UnitD_ON())
pin(18)=0
next
end sub

Sub ValveD_OFF
pin(18)=0
bitbanger(18,28,StartS())
for repeater =1 to 12
pin(18)=0
bitbanger(18,42,UnitNbrV())
bitbanger(18,40,lengthsA())
pin(18)=0
bitbanger(18,28,lengthsB())
pin(18)=0
bitbanger(18,22,UnitD_OFF())
pin(18)=0
next
end sub

Sub Valve1_ON
pin(18)=0
bitbanger(18,28,StartS())
for repeater =1 to 12
pin(18)=0
bitbanger(18,42,UnitNbrV())
bitbanger(18,40,lengthsA())
pin(18)=0
bitbanger(18,28,lengthsB())
pin(18)=0
bitbanger(18,22,UnitA_ON())
pin(18)=0
next
end sub

Sub Valve1_OFF
pin(18)=0
bitbanger(18,28,StartS())
for repeater =1 to 12
pin(18)=0
bitbanger(18,42,UnitNbrV())
bitbanger(18,40,lengthsA())
pin(18)=0
bitbanger(18,28,lengthsB())
pin(18)=0
bitbanger(18,22,UnitA_OFF())
pin(18)=0
next
end sub
CSub bitbanger 'pin number, number of bits, floating point array of bit lengths in usec
00000000
27BDFFC0 AFBF003C AFBE0038 AFB70034 AFB60030 AFB5002C AFB30024 AFB20020
AFB1001C AFB00018 AFB40028 3C109D00 8E030000 00808821 8E020080 8C640000
00A09021 00002821 00C0B021 0040F809 8E140064 00409821 8E02009C 3C0449F4
0040F809 24842400 00402821 0280F809 02602021 0040B821 8E240000 8E020024
24050007 0040F809 241E0001 AFA20010 8E020028 0040F809 8E240000 8E520000
8E030040 005EF004 0060F809 00122080 AFA20014 12400013 0040A821 0000A021
00008821 3C139D00 0014A080 02D41821 8C640000 8E620058 8E70007C 0040F809
02E02821 26310001 0200F809 00402021 02B4A021 0232182B AE820000 1460FFF2
0220A021 8FA30014 3C040008 8C620000 2442FFFD AC620000 3C03BF88 AC641064
3C03BF88 00001021 AC601068 40824800 8FA50014 8FA30010 2652FFFF AC7E0000
8CA40000 00442021 40024800 0044182B 1460FFFD 00000000 1640FFF6 24A50004
8FBF003C 3C020008 3C03BF88 AC621064 3C03BF88 8FBE0038 8FB70034 8FB60030
8FB5002C 8FB40028 8FB30024 8FB20020 8FB1001C 8FB00018 AC621068 03E00008
27BD0040
End CSub



RonEdited by RonnS 2017-02-25
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 844
Posted: 05:10pm 27 Feb 2017
Copy link to clipboard 
Print this post

Hi Ron,

I have spliced my code into yours and modified to what I think your protocol uses. i.e a header, 32 bits and a footer.
Your code needs 4 bitbanger inversions per bit but the ARLEC code only need 2.

The code below runs and puts out pulses so your can try/adjust it.

The code's fundamental period is set as 300us for a short, a long is 4 times that at 1200uS.

Regards
Gerry


  Quote  
'puls generator from P.Mather
option autorun on
'cpu 48
option explicit
option default NONE
dim integer repeater
dim string comand
'setpin 18,DOUT
'pin(18)=1
'Dim Float StartS(27)=(270, 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, 270 , 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, 380, 155, 325)
'dim float UnitNbrV(41)=(245, 2475, 352, 195, 337, 1200, 345, 1200, 345, 229, 314, 225, 314, 1200, 318, 226, 314, 1200, 314, 228, 307, 1334, 320, 235, 304, 1247, 304, 245, 302, 1252, 302, 1243, 305, 244, 305, 250, 300, 1276, 278, 239, 304, 660)'lst Val reduced from 1200
'' <header > 0 1 0 0 0 0 0 1 1 1
'dim float lengthsA(39)=(330, 200, 330, 1200, 330, 214, 330, 1224, 330, 1211, 330, 212, 330, 1200, 330, 214, 330, 1212, 330, 220, 330, 1220, 330, 220, 330, 220, 330, 1230, 330, 220, 330, 1220, 330, 220, 330, 1230, 330, 220, 330, 660)
'' 0 0 1 1 1 1 0 0 0 0
'dim float lengthsB(27)=(330, 300, 330, 1232, 320, 300, 330, 1233, 320, 300, 320, 1233, 320, 300, 320, 1220, 330, 300, 330, 1225, 330, 300, 330, 1220, 330, 300, 330, 660)
'' 0 0 0 0 0 0 0
'dim float UnitA_ON(21) =(330, 1220, 330, 300, 330, 300, 330, 1220, 320, 300, 320, 1200, 340, 207, 340, 1213, 340, 1208, 340, 206, 340, 10600)
'dim float UnitA_OFF(21)=(330, 300, 330, 1220, 330, 300, 330, 1220, 320, 300, 320, 1200, 340, 207, 340, 1213, 340, 1208, 340, 206, 340, 10600)
'' < ON/OFF 0 > < 0 > < 0 > < 0 > < 1 >< footer >
'' < UNIT A= 1 >< footer >
'
'dim float UnitD_ON(21) =(330, 1220, 330, 300, 330, 300, 330, 1220, 340, 1208, 300, 300, 240, 207, 300, 1213, 300, 240, 340, 1200, 340, 10600)
'dim float UnitD_OFF(21)=(330, 300, 330, 1220, 330, 300, 330, 1220, 340, 1208, 300, 300, 240, 200, 300, 1213, 300, 240, 340, 1213, 340, 10600)
'' < ON 1 /OFF 0 > < 0 > < 1 > < 0 > < 0 >< footer >
' < UNIT D= 4 >< footer >
'array of bit lengths in usec
'The ARLEC Coding.
' 1= long,short |---|_ ie 2 inversions by bitbanger
' 0= short,long |-|___ ie 2 inversions by bitbanger


' Your Coding for 0 and 1 s
' 1 = short,long,short,short |-|___|-|_ ie 4 inversions by bitbanger
' 0= short,short,short,long |-|_|-|___ ie 4 inversions by bitbanger
' The 32 bit code as 0 and 1 based on data above.
' The header and footers are added to the front and end of the code respectively.

dim integer Aon%= &B01000001110011110000000000010001 'A on
dim integer Aoff%= &B01000001110011110000000000000001 'A off
dim integer Don%= &B01000001110011110000000000010100 'A on
dim integer Doff%= &B01000001110011110000000000000100 'A off
'
'code setup for ARLEC

'dim float lengths(68)

' set up the code and pin details
'dim integer numberofbitsincode=32 'number of bits in the code.
'dim integer pulsecount=numberofbitsincode*2 'number of inversions in the code ie. 1 down + 1 up per bit in the code
'dim float pulselength=270 'the number of microseconds for the basic short pulse length A long is 3 times this
'dim integer repeat=15 'number of times to repeat the transmission


'Modified to match your data
dim integer code%
dim float lengths(132) ' 128 transitions for the 32 bits, and 2 each for the header and foooter 128+2+2=132

dim integer xmitpin=18 ' the pin connected to the 433mhz module data pin
'Pin 50 is for XMit on 433MHZ XMitter
PIN(xmitpin)=0 ' set the data pin low
SetPin xmitpin, DOUT ' set it as an output


' set up the code and pin details
dim integer numberofbitsincode=32 'number of bits in the code.
dim integer pulsecount=numberofbitsincode*4 'number of inversions in the code ie. 1 down + 1 up per bit in the code
dim float pulselength=300 'the number of microseconds for the basic short pulse length A long is 4 times this ie 1200
dim integer repeat=12 'number of times to repeat the transmission






do
input comand
if comand = "a" then
'Pause 500:Valve1_ON:
code%=Aon%
SEND433MHZ(pulsecount,pulselength,repeat,xmitpin,code%)
end if
if comand = "aa" then
'Pause 500:Valve1_OFF:
code%=Aoff%
SEND433MHZ(pulsecount,pulselength,repeat,xmitpin,code%)
end if
if comand = "d" then
':ValveD_ON:
code%=Don%
SEND433MHZ(pulsecount,pulselength,repeat,xmitpin,code%)
end if
if comand = "dd" then
':ValveD_OFF:
code%=Doff%
SEND433MHZ(pulsecount,pulselength,repeat,xmitpin,code%)
end if
loop


SUB SEND433MHZ(pulsecount as integer,pulselength as float,repeat as integer ,thexmitpin as integer,senddata% as integer)

local integer savedata%=senddata%
local integer long,short
local integer repeatpause,j,i
'long=pulselength*3-.15 'fudge for Mx170 at 48 MHz
short=pulselength
'long=pulselength*3
long=pulselength*4
repeatpause=long*
10/1000 'is millseconds so divide by 1000
for j=0 to repeat-1

' send the header bits
lengths(0)=short
lengths(
1)=long*2
senddata%=savedata%
for i=2 to pulsecount+1 step 4
if senddata% and &H80000000 then
'One
lengths(i)=short
lengths(i+
1)=long
lengths(i+
2)=short
lengths(i+
3)=short

ELSE
'Zero
lengths(i)=short
lengths(i+
1)=short
lengths(i+
2)=short
lengths(i+
3)=long
end if
senddata%=senddata%<<
1
next i
' send the footer bits
lengths(pulsecount+2)=short
lengths(pulsecount+
3)=long
' Call the CFunction
bitbanger(thexmitpin,132,lengths())
pause repeatpause ' pause between repetitions
next j

end SUB






'Sub ValveD_ON
'pin(18)=0
'bitbanger(18,28,StartS())
'for repeater =1 to 12
'pin(18)=0
'bitbanger(18,42,UnitNbrV())
'bitbanger(18,40,lengthsA())
'pin(18)=0
'bitbanger(18,28,lengthsB())
'pin(18)=0
'bitbanger(18,22,UnitD_ON())
'pin(18)=0
'next
'end sub
'
'Sub ValveD_OFF
'pin(18)=0
'bitbanger(18,28,StartS())
'for repeater =1 to 12
'pin(18)=0
'bitbanger(18,42,UnitNbrV())
'bitbanger(18,40,lengthsA())
'pin(18)=0
'bitbanger(18,28,lengthsB())
'pin(18)=0
'bitbanger(18,22,UnitD_OFF())
'pin(18)=0
'next
'end sub
'
'Sub Valve1_ON
'pin(18)=0
'bitbanger(18,28,StartS())
'for repeater =1 to 12
'pin(18)=0
'bitbanger(18,42,UnitNbrV())
'bitbanger(18,40,lengthsA())
'pin(18)=0
'bitbanger(18,28,lengthsB())
'pin(18)=0
'bitbanger(18,22,UnitA_ON())
'pin(18)=0
'next
'end sub
'
'Sub Valve1_OFF
'pin(18)=0
'bitbanger(18,28,StartS())
'for repeater =1 to 12
'pin(18)=0
'bitbanger(18,42,UnitNbrV())
'bitbanger(18,40,lengthsA())
'pin(18)=0
'bitbanger(18,28,lengthsB())
'pin(18)=0
'bitbanger(18,22,UnitA_OFF())
'pin(18)=0
'next
'end sub
CSub bitbanger 'pin number, number of bits, floating point array of bit lengths in usec
00000000
27BDFFC0 AFBF003C AFBE0038 AFB70034 AFB60030 AFB5002C AFB30024 AFB20020
AFB1001C AFB00018 AFB40028
3C109D00 8E030000 00808821 8E020080 8C640000
00A09021 00002821 00C0B021 0040F809 8E140064 00409821 8E02009C 3C0449F4
0040F809 24842400 00402821 0280F809 02602021 0040B821 8E240000 8E020024
24050007 0040F809 241E0001 AFA20010 8E020028 0040F809 8E240000 8E520000
8E030040 005EF004 0060F809 00122080 AFA20014 12400013 0040A821 0000A021
00008821 3C139D00 0014A080 02D41821 8C640000 8E620058 8E70007C 0040F809
02E02821 26310001 0200F809 00402021 02B4A021 0232182B AE820000 1460FFF2
0220A021 8FA30014 3C040008 8C620000 2442FFFD AC620000 3C03BF88 AC641064
3C03BF88 00001021 AC601068 40824800 8FA50014 8FA30010 2652FFFF AC7E0000
8CA40000 00442021 40024800 0044182B 1460FFFD 00000000 1640FFF6 24A50004
8FBF003C 3C020008 3C03BF88 AC621064 3C03BF88 8FBE0038 8FB70034 8FB60030
8FB5002C 8FB40028 8FB30024 8FB20020 8FB1001C 8FB00018 AC621068 03E00008
27BD0040
end CSub

Edited by disco4now 2017-03-01
Latest F4 Latest H7
 
RonnS
Senior Member

Joined: 16/07/2015
Location: Germany
Posts: 120
Posted: 06:07am 28 Feb 2017
Copy link to clipboard 
Print this post

Thank you Gerry,

i tried it immediately but it did not work I think I have 3 varieties of pulse lengths really, I will continue to work with your code and tell you about the results

best regards Ron
 
RonnS
Senior Member

Joined: 16/07/2015
Location: Germany
Posts: 120
Posted: 05:19am 08 Mar 2017
Copy link to clipboard 
Print this post

very good news,

hello Gerry, i have got it, your Code just running with my "smartwares" Parts i have done some adjustments and changes,particular at the 433Mhz Sub and now it works
for testing i have added a 4x3 keypad , and some new "Smartwares" parts_ a dimmable lampholder an an Wall mounted dimmer for switching and dimming lights

the big wrong point was the loop in the 433Mhz Sub to bitbang the codes out
the repeatloop may only affect the bitbang csub, elsewere the saturation need too much time ( all new calculations) and the polarity is reversed .----- if not so

the code for the Arctec_switch_protocol with 3 Units:
'puls generator from P.Mather
option autorun on
'cpu 48
option explicit
option default NONE
dim integer repeater
dim string comand
dim float KeyCode
Keypad KeyCode, KP_Int, 2, 3, 4, 5, 6, 7, 21 ' 4x3 keyboard


' Coding for 0 and 1 s
' 1 = short,long,short,short |-|___|-|_ ie 4 inversions by bitbanger
' 0= short,short,short,long |-|_|-|___ ie 4 inversions by bitbanger
' The 32 bit code as 0 and 1 based on data above.
' The header and footers are added to the front and end of the code respectively.

dim integer Aon%= &B01000001000011110000000000010001 'A on
dim integer Aoff%= &B01000001000011110000000000000001 'A off
dim integer Don%= &B01000001000011110000000000010100 'D on
dim integer Doff%= &B01000001000011110000000000000100 'D off
dim integer LHon%= &B01000001000011110000000000011010 'LH on
dim integer LHoff%=&B01000001000011110000000000001010 'LH off

dim integer code%
dim float lengths(131) ' 128 transitions for the 32 bits, and 2 each for the header and foooter 128+2+2=132 -1
dim integer xmitpin=18 ' the pin connected to the 433mhz module data pin
PIN(xmitpin)=0 ' set the data pin low
SetPin xmitpin, DOUT ' set it as an output


' set up the code and pin details
dim integer numberofbitsincode=32 'number of bits in the code.
dim integer pulsecount=numberofbitsincode*4 'number of inversions in the code ie. 1 down + 1 up per bit in the code
dim float pulselength=300 'the number of microseconds for the basic short pulse length A long is 4 times this ie 1200
dim integer repeat=12 'number of times to repeat the transmission

do

if KeyCode = 1 then
'Pause 500:Valve1_ON:
code%=Aon%
SEND433MHZ(pulsecount,pulselength,repeat,xmitpin,code%)
KeyCode = 101
end if
if KeyCode = 2 then
'Pause 500:Valve1_OFF:
code%=Aoff%
SEND433MHZ(pulsecount,pulselength,repeat,xmitpin,code%)
KeyCode = 102
end if
if KeyCode = 3 then
':ValveD_ON:
code%=Don%
SEND433MHZ(pulsecount,pulselength,repeat,xmitpin,code%)
KeyCode = 103
end if
if KeyCode = 4 then
':ValveD_OFF:
code%=Doff%
SEND433MHZ(pulsecount,pulselength,repeat,xmitpin,code%)
KeyCode = 104
end if
if KeyCode = 5 then
':ValveD_ON:
code%=LHon%
SEND433MHZ(pulsecount,pulselength,repeat,xmitpin,code%)
KeyCode = 105
end if
if KeyCode = 6 then
':ValveD_OFF:
code%=LHoff%
SEND433MHZ(pulsecount,pulselength,repeat,xmitpin,code%)
KeyCode = 106
end if
loop


SUB KP_Int ' a key press has been detected
PRINT "Key press = " KeyCode
pause 50
END SUB


SUB SEND433MHZ(pulsecount as integer,pulselength as float,repeat as integer ,thexmitpin as integer,senddata% as integer)

local integer savedata%=senddata%
local integer long,short,mini,maxi,prelong
local integer j,i
'long=pulselength*3-.15 'fudge for Mx170 at 48 MHz
short=pulselength
mini=pulselength-50
maxi=pulselength*27
long=pulselength*4
prelong=short*8

rem for j=0 to repeat-1

' send the header bits
lengths(0)=short
lengths(1)=prelong
senddata%=savedata%
for i=2 to pulsecount+1 step 4
if senddata% and &H80000000 then
'One
lengths(i)=short
lengths(i+1)=long
lengths(i+2)=short
lengths(i+3)=mini

ELSE
'Zero
lengths(i)=short
lengths(i+1)=mini
lengths(i+2)=short
lengths(i+3)=long
end if
senddata%=senddata%<<1
next i
' send the footer bits
lengths(pulsecount+2)=short
lengths(pulsecount+3)=maxi
' Call the CFunction
for j=0 to repeat-1
bitbanger(thexmitpin,132,lengths())
next j

end SUB

CSub bitbanger 'pin number, number of bits, floating point array of bit lengths in usec
00000000
27BDFFC0 AFBF003C AFBE0038 AFB70034 AFB60030 AFB5002C AFB30024 AFB20020
AFB1001C AFB00018 AFB40028 3C109D00 8E030000 00808821 8E020080 8C640000
00A09021 00002821 00C0B021 0040F809 8E140064 00409821 8E02009C 3C0449F4
0040F809 24842400 00402821 0280F809 02602021 0040B821 8E240000 8E020024
24050007 0040F809 241E0001 AFA20010 8E020028 0040F809 8E240000 8E520000
8E030040 005EF004 0060F809 00122080 AFA20014 12400013 0040A821 0000A021
00008821 3C139D00 0014A080 02D41821 8C640000 8E620058 8E70007C 0040F809
02E02821 26310001 0200F809 00402021 02B4A021 0232182B AE820000 1460FFF2
0220A021 8FA30014 3C040008 8C620000 2442FFFD AC620000 3C03BF88 AC641064
3C03BF88 00001021 AC601068 40824800 8FA50014 8FA30010 2652FFFF AC7E0000
8CA40000 00442021 40024800 0044182B 1460FFFD 00000000 1640FFF6 24A50004
8FBF003C 3C020008 3C03BF88 AC621064 3C03BF88 8FBE0038 8FB70034 8FB60030
8FB5002C 8FB40028 8FB30024 8FB20020 8FB1001C 8FB00018 AC621068 03E00008
27BD0040
end CSub
Edited by RonnS 2017-03-09
 
RonnS
Senior Member

Joined: 16/07/2015
Location: Germany
Posts: 120
Posted: 11:03am 19 Mar 2017
Copy link to clipboard 
Print this post

hello guys,

these simple LED-Strip-Light-Single-Color-Dimmer-Switch, banggood link
could be easily controlled
i have running these part as additional and ambiente lightning since many years in my living room it was only controllable by a small remote control..until now ! Now that makes this the micromiteMM MK2 MuP Board with a good (plastic)keypad like this from Altronic

simple code snipped for on and of switching
'puls generator from P.Mather
'idea of the 433Mhz sub by discofornow(gerry)
option autorun on
'cpu 48
option explicit
option default NONE
dim integer repeater
dim string comand
dim float KeyCode=1000
Keypad KeyCode, KP_Int, 2, 3, 4, 5, 6, 7, 21 ' 4x3 keyboard

'array of bit lengths in usec
' 1= long,short |---|_ ie 2 inversions by bitbanger
' 0= short,long |-|___ ie 2 inversions by bitbanger


dim integer NVSW%= &B010000011011110000100001 'A off

'dim float lengths(68)

' set up the code and pin details
'dim integer numberofbitsincode=32 'number of bits in the code.
'dim integer pulsecount=numberofbitsincode*2 'number of inversions in the code ie. 1 down + 1 up per bit in the code
'dim float pulselength=270 'the number of microseconds for the basic short pulse length A long is 3 times this
'dim integer repeat=15 'number of times to repeat the transmission


'Modified to match your data
dim integer code%
dim integer xmitpin=18 ' the pin connected to the 433mhz module data pin
PIN(xmitpin)=0 ' set the data pin low
SetPin xmitpin, DOUT ' set it as an output
' set up the code and pin details
dim float lengths(98)

' set up the code and pin details
dim integer numberofbitsincode=24 'number of bits in the code.
dim integer pulsecount=numberofbitsincode*2 'number of inversions in the code ie. 1 down + 1 up per bit in the code
dim float pulselength=400 'the number of microseconds for the basic short pulse length A long is 3 times this
dim integer repeat=16 'number of times to repeat the transmissio






do

if KeyCode = 0 then

code%=NVSW%
SEND433MHZ(pulsecount,pulselength,repeat,xmitpin,code%)
KeyCode = 101
end if

loop


SUB KP_Int ' a key press has been detected
PRINT "Key press = " KeyCode
pause 50
END SUB

SUB SEND433MHZ(pulsecount as integer,pulselength as float,repeat as integer ,thexmitpin as integer,senddata% as integer)

local integer savedata%=senddata%
local integer long,short,prelong
local integer repeatpause,j,i
'long=pulselength*3-.15 'fudge for Mx170 at 48 MHz
short=pulselength
prelong=pulselength*6
long=pulselength*3
repeatpause=long*10/1000 'is millseconds so divide by 1000
' send the header bits
lengths(0)=short 'DEBUG
lengths(1)=prelong 'DEBUG

senddata%=savedata%
for i=2 to pulsecount-1 step 2
if senddata% and &H800000 then ' minus 2 für 24 bytes &H80000000
'One
lengths(i)=long
lengths(i+1)=short

ELSE
'Zero
lengths(i)=short
lengths(i+1)=long
END if
senddata%=senddata%<<1
next i
' send the stop bits
' lengths(pulsecount+1)=short 'DEBUG
' lengths(pulsecount+2)=prelong 'DEBUG
' Call the CFunction
for j=0 to repeat-1
bitbanger(thexmitpin,108,lengths())
rem pause repeatpause ' pause between repetitions
next j

END SUB



CSub bitbanger 'pin number, number of bits, floating point array of bit lengths in usec
00000000
27BDFFC0 AFBF003C AFBE0038 AFB70034 AFB60030 AFB5002C AFB30024 AFB20020
AFB1001C AFB00018 AFB40028 3C109D00 8E030000 00808821 8E020080 8C640000
00A09021 00002821 00C0B021 0040F809 8E140064 00409821 8E02009C 3C0449F4
0040F809 24842400 00402821 0280F809 02602021 0040B821 8E240000 8E020024
24050007 0040F809 241E0001 AFA20010 8E020028 0040F809 8E240000 8E520000
8E030040 005EF004 0060F809 00122080 AFA20014 12400013 0040A821 0000A021
00008821 3C139D00 0014A080 02D41821 8C640000 8E620058 8E70007C 0040F809
02E02821 26310001 0200F809 00402021 02B4A021 0232182B AE820000 1460FFF2
0220A021 8FA30014 3C040008 8C620000 2442FFFD AC620000 3C03BF88 AC641064
3C03BF88 00001021 AC601068 40824800 8FA50014 8FA30010 2652FFFF AC7E0000
8CA40000 00442021 40024800 0044182B 1460FFFD 00000000 1640FFF6 24A50004
8FBF003C 3C020008 3C03BF88 AC621064 3C03BF88 8FBE0038 8FB70034 8FB60030
8FB5002C 8FB40028 8FB30024 8FB20020 8FB1001C 8FB00018 AC621068 03E00008
27BD0040
end CSub



attention ! You have to modify the 433mhzsub in the place of the logical operation
for only 24 bytes you need :
if senddata% and &H800000 then ' for 24 bytes for 32 bytes use &H80000000


Much success with the try

regards Ron
Edited by RonnS 2017-03-21
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024