thanks for sharing Alan.
One remark : i see cbi/sbi which will work fine but you can best use SET/RESET or just PORTX.y= 1|0 , bascom will make exact the same cbi/sbi instructions.
The advantage : when you change processor and it does not have these ports at the low address , cbi/sbi will not work.
bascom will create the proper code in that case. so for better portability between chips it is best to use basic instead of asm.
↧
Share your working BASCOM-AVR code here : RHT03 (DHT22) Sensor : REPLY
↧
BASCOM-AVR : Calculator percent error rate in the port : REPLY
Hardware baud rates are fixed by the available divisor ratios in the chip hardware, in combination with the crystal frequency used. And for some crystal values, the available divisor ratios mean you cannot achieve some baud rates, so its worth displaying the error as a warning. Hence its possible and useful to calculate the baud rate error.
For a software UART, the timing is done purely by computing suitable delays ( software loops ) within the software, so in principle you should not get any significant error. So there is not much point in displaying it. There will of course be residual round-off errors, but for low baud rates, these should not give any transmission errors.
Baud rate errors of up to 2% or so should not result in transmission errors, regardless of whether you use hardware or software UARTs.
↧
↧
Share your working BASCOM-AVR code here : Decoding Sony Remote With Bascom AVR : NEWTOPIC
Hello,
I found a method to decode sony ir on the web and used it with Bascom AVR. It uses external interrupt and pulsin command to decode ir signal.
[code:1:edc0ac56af]
$regfile = "m8def.dat"
$crystal = 4000000
$hwstack = 128
$swstack = 256
$framesize = 256
$baud = 9600
Config Lcd = 16x2
Config Lcdpin = Pin , Db4 = Portc.3 , Db5 = Portc.2 , Db6 = Portc.1 , Db7 = Portc.0 , E = Portc.4 , Rs = Portb.1
Dim Ir_pulse(7) As Word
Dim I As Byte
Dim Dbyte As Byte
Dim Length As Word
Cls
Lcd "Bismillah"
Wait 2
Cls
Config Pind.2 = Input
Portd.2 = 1
On Int0 Int_0isr
Enable Int0
Enable Interrupts
Do
nop
Loop
Int_0isr:
'/////Check///////
'Disable Int0
' Pulsein Length , Pind , 2 , 0
' For I = 1 To 7
' Pulsein Ir_pulse(i) , Pind , 2 , 0
' Next I
' For I = 1 To 7
' Lcd "No.: " ; I ; ", " ; Ir_pulse(i)
' Wait 1
' Cls
' Next I
'Enable Int0
'/////Check///////
Disable Int0
Pulsein Length , Pind , 2 , 0
If Length > 200 Then
For I = 1 To 7
Pulsein Ir_pulse(i) , Pind , 2 , 0
Next I
Dbyte = &H7F
If Ir_pulse(1) < 100 Then
Dbyte.0 = 0
End If
If Ir_pulse(2) < 100 Then
Dbyte.1 = 0
End If
If Ir_pulse(3) < 100 Then
Dbyte.2 = 0
End If
If Ir_pulse(4) < 100 Then
Dbyte.3 = 0
End If
If Ir_pulse(5) < 100 Then
Dbyte.4 = 0
End If
If Ir_pulse(6) < 100 Then
Dbyte.5 = 0
End If
If Ir_pulse(7) < 100 Then
Dbyte.6 = 0
End If
Dbyte = Dbyte + 1
Lcd Dbyte
Wait 1
Cls
End If
Enable Int0
Return
[/code:1:edc0ac56af]
Please let me know if you find any mistake or way to improve it more.
Thanks.
↧
Share your working BASCOM-AVR code here : RHT03 (DHT22) Sensor : REPLY
Thanks Mark. I always appreciate your comments.
A few years ago when I was trying to get my autopilot to work I had problems in that, at times, the tiller would not respond properly. This was always a shock when I was forward working with a headsail and all of a sudden the boat would starting heading downwind.
It seemed like when I went to the sbi/cbi instructions the problem went away.
But like so many times for me in programming my "fix" probably had nothing to do with the problem.
Alan
↧
Share your working BASCOM-AVR code here : Decoding Sony Remote With Bascom AVR : REPLY
Hello rabiuls
I have a complete how too in the blog section with a number of programs and I seem to be able to decode anything now even the DHT11/22 sensors. It started only as a way to decode IR-remotes but is proving much more versatile
http://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=11304
You do not need to know what is transmitted as I have made an auto-stor which records the codes to eeprom so turning this on you record the buttons of the remote and use the location in eeprom to compare what is sent for the button pressed.
Regards Paul
↧
↧
Share your working BASCOM-AVR code here : RHT03 (DHT22) Sensor : REPLY
Here is the code using Pulsein and an interrupt to get data from the DHT11/22
NOTE The MCS library needs to be modified for this to work!!!!
This code processes the bytes from the sensor
[code:1:005b576c8c]
Flag = 1 'start at byte 1
Bx = 0
Px = 31 'start at bit 0
Call Call_dht11 'wake up DHT11
Waitms 100 'DHT11/22 talking
Disable Capture1
'DEBUG
' Print "BX>" ; Bx
' For X = 1 To 44
'Print ">>>>>>" ; Temps(x)
'Next
'Print "FLAG>" ; Flag
Shift Datagotdht(1) , Left , 1
Shift Datagotdht(2) , Left , 2
'DEBUG
'--print the values we get
'For Bx = 1 To 2
'Print "byte>" ; Bx ; "<>" ; Bin(datagotdht(bx))
'Next
Datawrk = Datagotdht(1)
'DEBUG
'Print "dwork>" ; Bin(datawrk)
'Print "VAL-1>" ; Bin(chopswrk(2))
'Print "VAL-2>" ; Bin(chopswrk(4))
X = Chopswrk(4)
Shift X , Right , 4
Tmpstr1 = Str(x)
'Print "one>" ; Tmpstr1
X = Chopswrk(4)
Shift X , Left , 4
Shift X , Right , 4
Tmpstr2 = Str(x)
'Print "two>" ; Tmpstr2
'CRC
Tmpstr3 = Tmpstr1 + Tmpstr2
X = Chopswrk(2)
Shift X , Right , 4
Tmpstr1 = Str(x)
X = Chopswrk(4)
Shift X , Left , 4
Shift X , Right , 4
Tmpstr2 = Str(x)
Tmpstr4 = Tmpstr1 + Tmpstr2
'Print "number is>" ; Tmpstr3
Print "Temp is>" ; Hexval(tmpstr4) ; " Deg c"
Print "Humidity>" ; Hexval(tmpstr3) ; "%"
X = Chopswrk(2) + Chopswrk(4)
Datawrk = Datagotdht(2)
Carc = Chopswrk(4)
Print "X>" ; X 'our calculated CRC
Print "CRC>" ; Carc 'the CRC frm the DHT11/22
[/code:1:005b576c8c]
This code wakes up the sensor and also has the ISR code
[code:1:005b576c8c]
'-----------------------------------------------------------------------------------
' NOTE THIS REQUIRES A MODIFICATION TO THE MCS LIBRARY THIS IS TALKED ABOUT IN THE
' PULSEIN HELP. The value Genus(9) is changed to Genus(1) Making changes to this library
' means that when an update happens it will go back to the Genus(9)
' Always be careful back up the library first!!!!
'
'----------------------------------------------------------------------------------
'-----------------------------------------
'--This ISR reads the data from the DHT11
'Dim Datagotdht(2) As Long '5 bytes for DHT11
'Dim Datawrk As Long
'Dim Chopswrk(4) As Byte At Datawrk Overlay
'Dim Carc As Byte
'Dim X As Byte
'Dim Bx As Byte
'Dim Px As Byte
'Dim Flag As Byte 'increment for each long
'Dht_put Alias Portd.6
'Dht_get Alias Pind.6
'Dht_io_set Alias Ddrd.6
'--this wakes up the DHT11 so it will send its data
Sub Call_dht11
Set Dht_io_set
Reset Dht_put
Waitms 25
Set Dht_put
Waitus 40
Reset Dht_io_set
'this sets up for the DHT11/22 to send
'we disable it after we get all the bytes
Enable Capture1
End Sub
'---This gets the pulse length and decides if its "0" or "1"
Dht_11:
Pulsein Length , Pind , 6 , 1 'here we measure the length of the pulse
' Temps(bx) = Length 'DEBUG records the pulse lengths to print later
Select Case Length
Case Is < 14 'adjust for timing as seen in
'PROTOCOL_TEST_TIMING
Datagotdht(flag).px = 0
Case Is < 35
Datagotdht(flag).px = 1
End Select
Decr Px
'Incr Bx 'DEBUG
If Px = 0 Then
Incr Flag
Px = 31
End If
Return
[/code:1:005b576c8c]
Regards Paul
↧
BASCOM-AVR : Binary encoded hex values to decimal eg DHT11 : NEWTOPIC
I have only been able to convert the hex values in the binary bytes to decimal values by first making them strings is there a better way to convert say 0010-0110 > 26 hex > 38 decimal I can not find a command in Bascom to do it.
Regards Paul
[b:97df1e0c47][color=red:97df1e0c47](BASCOM-AVR version : 2.0.7.6 )[/b:97df1e0c47][/color:97df1e0c47]
↧
BASCOM-AVR : Binary encoded hex values to decimal eg DHT11 : REPLY
I don't get your point.
If you store the decimal value of 38 in any byte, it will still remain the value of say 38 apples.
It is a matter of notation if you want to write that down as 38 paintetd apples, the decimal 38 (= (3 x 10) + (8 x 1)), the HEX26 (= (2 x 16) + (6 x 1)), or BINARY00100110 (= 0x128 + 0x64 + 1x32 +0x16......).
As the physical chip can only store the two values of 0 and 1, it will use binary in its inner brain.
First question:
Where does you binary value come from? Is it stored in a byte? Or is it a string (S='00100110')?
Second question:
what are you going to do with that value?
Do you want to store its value, its string representation in dec, bin, oct, hex?
Do you want to print it in any representation?
I cannot see all that from your question!
Marc
↧
Share your working BASCOM-AVR code here : Decoding Sony Remote With Bascom AVR : REPLY
@Paulvk, this would be very nice to decode any remote - a ballpark value for keys. I visited your link and there are several files. Can you please tell me which file should I download (good, if there is an example) to test?
Thanks in advance.
↧
↧
BASCOM-AVR : Binary encoded hex values to decimal eg DHT11 : REPLY
Doh! I worked through the data sheet converting their formula just need some sleep I think!
↧
Share your working BASCOM-AVR code here : Decoding Sony Remote With Bascom AVR : REPLY
If you work through the blog step by step you will first load the program that shows you the timing of the pulses this enables you to change the values in the ISR in the second program that that prints the values from the IR-remote this confirms its working and you can see the values. The last program is the self-storing one it starts at location one and moves up one for each code it receives so if it is activated by placing a ground on the pin and re-setting the AVR it is in stor mode waiting for you to press a button to stor its code. Now to make things simple in the programs I use location one for the button with a one on it right up to button 0 which is location 10. If you have a look at the Watering System Controller blog you can see me using it and all the parts are in their own files ready to be used in your own projects.
I had a look at the Sony timing my programs should work with no changes.
Regards Paul
↧
Share your working BASCOM-AVR code here : Decoding Sony Remote With Bascom AVR : REPLY
Thank you Paul. I shall try to understand from the start, it may take time. But it is good to have a method to decode any IR signal.
Where is the link for Watering System Controller blog?
Best regards.
↧
Share your working BASCOM-AVR code here : Decoding Sony Remote With Bascom AVR : REPLY
It is in the blog section of this forum http://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewforum&f=19
↧
↧
Share your working BASCOM-AVR code here : Decoding Sony Remote With Bascom AVR : REPLY
Thanks Paul. I did not know that this forum is also having a blog. That's good :).
↧
BASCOM-AVR : Binary encoded hex values to decimal eg DHT11 : REPLY
In some instances, for example displays that take binary decimal adjusted bytes, then B0010_0110=H26=dec38=B0011_1000decimal adjusted binary nibbles.
Or did something change lately?
Hubert
↧
BASCOM-AVR : Binary encoded hex values to decimal eg DHT11 : REPLY
[quote:169d697c88="Paulvk"]I can not find a command in Bascom to do it.[/quote:169d697c88]
Simpy use MakeBCD.
↧
BASCOM-AVR : Need Help MAX7456 : REPLY
[URL=http://radikal.ru/F/s020.radikal.ru/i717/1304/9a/010e2750628d.jpg.html][img:12a30a2145]http://s020.radikal.ru/i717/1304/9a/010e2750628dt.jpg[/img:12a30a2145][/URL]
↧
↧
Share your working BASCOM-AVR code here : Poor man's Rolex.... : REPLY
Hi Ben.
Altered your code under the 8-bit connection - works. Tried to translate into Russian language - a problem: instead of letters does not appear to understand icons. Do not tell me what could be wrong?
Thanks in advance.
↧
BASCOM-AVR : Random output pin toggling : REPLY
No ideas? :?
↧
Share your working BASCOM-AVR code here : Poor man's Rolex.... : REPLY
What I see is that you tried to translate the days of the week
[code:1:e2e7213008]'-------------------------------------------------------------------------------
' lookup voor dag van de week
'-------------------------------------------------------------------------------
Weekdays:
'Data "maandag" , "dinsdag" , "woensdag" , "donderdag" , "vrijdag" , "zaterdag" , "zondag"
Data "Ïîíåäåëüíèê" , "Âòîðíèê" , "Ñðåäà" , "×åòâåðã" , "Ïÿòíèöà" , "Ñóááîòà" , "Âîñêðåñåíüå"
'---------------------------------------------------------------
[/code:1:e2e7213008]
These characters are taken from these two font-files.
font12x16.font
font8x12.font
If you want to use different charakters (Cyrillic) you will have to change them in the font-files. There is a font-designer at tools.
Have fun
Ben Zijlstra
↧