Manchester coding

For wireless communication you need Manchester coding. Manchester code provides simple encoding with no long period without a level transition. This helps clock recovery.
Here ‘s is a simple sample for a transmitter and receiver written in Bascom-avr.
1 will be coded as 01
0 will be coded as 10
00 and 11 are invalid
For the receiving part in VB6 check here .

Declare Function Make_manchester(byval Temp As Byte) As Word
Declare Function Decode_manchester(byval Tempw As Word ) As Byte



'== Demo prog ==
Dim Lus As Byte
Do
For Lus = 0 To 255
   Tempword = Make_manchester(lus)
   Print Decode_manchester(tempword)
Next Lus
Loop
End

 

'Subroutines
Sub Make_manchester(byval Temp As Byte) As Word
Local Bit_number As Byte
Local Manchester As Word
Bit_number = 8
Do
Shift Manchester , Left , 2
Decr Bit_number
If Temp.bit_number = 1 Then
Manchester = Manchester + 1                                 '01
Else
Manchester = Manchester + 2                                 '10
End If
Loop Until Bit_number = 0
Make_manchester = Manchester
End Sub


Sub Decode_manchester(byval Tempw As Word ) As Byte
Local Bit_number As Byte
Local Manchester As Word
Bit_number = 8
Do
Shift Manchester , Left , 1
Decr Bit_number
Temp_1 = Tempw And &B1100_0000_0000_0000
If Temp_1 = &B0100_0000_0000_0000 Then Incr Manchester      '01
If Temp_1 = &B1100_0000_0000_0000 Or Temp_1 = 0 Then Set Data_error       '11 or 00
Shift Tempw , Left , 2
Loop Until Bit_number = 0
If Data_error = 0 Then
   Decode_manchester = Manchester
Else
   Decode_manchester = 0
End If
Reset Data_error
End Sub
Vectron Veft-factuur

For the Vecton POS system I have build different modules. This is the “Veft-factuur” module.
It’s a standalone invoice module for the Vectron-pos, it don’t need Vcom to operate. It’s using Veft as communication platform with the ecr’s.
Due the communication with Tcp/ip it’s possible to create global network with 1 invoice server. Therefore it’s possible that the customers visit different locations with 1 account.
Veft-factuur is a direct invoice system, it’s not necessary as in Vcom to read first the sales (of all the tables) data in the backoffice and make then an invoice. You can make with “Veft-factuur” direct a invoice of a table. Very popular for Bowling and party centre’s, you can give the customer the invoice direct at the end of the evening.
Account management is done in “Veft-factuur”. Indentification at the ECR can be done with number, scancode, magnetic & chipcard or with an dropdown menu.

veft1
veft2
veft3
veft4
PlayPause
previous arrow
next arrow
 
veft1
veft2
veft3
veft4
previous arrow
next arrow
Vectron Stock

For the Vecton POS system I have build different modules. This is the stock module called “Medium stock”.
With this module you can manage you plu’s, make orders, print barcode labels, check your stock, sales report and more.
It’s the oldest of the modules and has proven itself with various customers.

medium1
medium2
medium3
medium4
medium5
PlayPause
previous arrow
next arrow
 
medium1
medium2
medium3
medium4
medium5
previous arrow
next arrow

 

Rgb dimmer fading

Rgb dimmers are most of the time dimming according figure 1. It’s simple code, just increase al the colors 1 step a time,  but the disadvange is that blue is ready first and red the last and that looks not that realistic. It would be neater when all 3 colors will start and finishing together as seen in figure 2.
This code will fade all colors together.
Timer3 is used to controle the 3 pwm channels.
Timer0 is the delay for the steps. It’s with this xtal and preload an delay of 20ms. If you are going to use a other crystal then you need recalculate the timer0 preload.

rgb1
rgb2
PlayPause
previous arrow
next arrow
 
rgb1
rgb2
previous arrow
next arrow

 

Syntax

Fade Red,Green,Blue,Steps

Remarks

 Red  Constant or variable with new RED value.
 Green  Constant or variable with new GREEN value.
 Blue  Constant or variable with new BLUE value.
 Steps  Number of steps to fade between old and new value

 

 

 

 

 

 

Dowload the code here 

See the code below in action;

 

$regfile = "m128def.DAT"
$crystal = 7372800
$baud = 19200


Config Timer3 = Pwm , Prescale = 64 , Pwm = 8 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down , Compare C Pwm = Clear Down
Config Timer0 = Timer , Prescale = 1024

On Ovf0 Rgbint
Enable Timer3
Enable Ovf0
Enable Interrupts
Start Timer3
Timer0 = &H70
Stop Timer0


Declare Sub Fade(byval Newrood As Byte , Byval Newgroen As Byte , Byval Newblauw As Byte , Byval Stappen As Byte)
Dim Staprood As Single
Dim Stapgroen As Single
Dim Stapblauw As Single
Dim Roodw As Single
Dim Blauww As Single
Dim Groenw As Single
Dim Stappen As Byte
Dim Temps As Single
Dim Tempint As Integer
Dim Stap2 As Byte

Rood Alias Compare3a
Blauw Alias Compare3b
Groen Alias Compare3c

Rood = 0
Blauw = 0
Groen = 0


Do
Fade 25 , 25 , 25 , 10
Wait 2
Fade 255 , 0 , 0 , 50
Wait 2
Fade 0 , 255 , 0 , 50
Wait 2
Fade 0 , 0 , 255 , 50
Wait 2
Fade 150 , 150 , 75 , 50
Wait 2
Fade 0 , 0 , 0 , 10
Wait 2
Fade 225 , 225 , 225 , 100
Wait 2
Loop




Sub Fade(newrood As Byte , Newgroen As Byte , Newblauw As Byte , Stappen As Byte )
Stap2 = Stappen
Roodw = Rood : Groenw = Groen : Blauww = Blauw
Temps = Newrood - Rood
Staprood = Temps / Stappen
Temps = Newgroen - Groen
Stapgroen = Temps / Stappen
Temps = Newblauw - Blauw
Stapblauw = Temps / Stappen
Start Timer0
End Sub


Rgbint:
Roodw = Roodw + Staprood
Groenw = Groenw + Stapgroen
Blauww = Blauww + Stapblauw
Tempint = Round(roodw)
Rood = Tempint
Tempint = Round(blauww)
Blauw = Tempint
Tempint = Round(groenw)
Groen = Tempint
Decr Stap2
If Stap2 = 0 Then
 Stop Timer0
End If
Timer0 = &H70
Return
Manchester Decode

This will decode the received manchester code on the pc-side, that’s coded by the Bascom sample .

'Manchester decoder VB5/6 Evert 2007 V1.0
Dim Mansword As Double
Mansword = Highbyte                                         'Make a word out of the high and low byte
Mansword = Mansword * 256
Mansword = Mansword + Lowbyte
Manchesterdecode = 0                                        'Set output to zero
For Lus = 1 To 8                                            'Run loop 8 times
Manchesterdecode = Manchesterdecode * 2                     'Shift the bit to the left
If(mansword And 49152) = 16384 Then                         'If the left 2 bits are 01
    Manchesterdecode = Manchesterdecode + 1                 ' Incr Output
End If
Mansword = Mansword * 4                                     'Shift bit 2x to the left
Next Lus
End Function