Quantcast
Channel: MCS Electronics Forum
Viewing all 20563 articles
Browse latest View live

BASCOM-AVR : Need debounce help : REPLY

$
0
0
Thank you , mark for the reply. The more I think about it though, my solution my not be so effective. Are my revised comments maybe what is really happening? The routine I wrote checks the switch a second time after 25ms, but what I think would be better is to make sure the switch was actually held low for AT LEAST 25ms. I am looking for an approach that would mandate that the button be pressed for a minimum time. Any advice how to code for that? Thanks so much do if pinb.4 = 0 then 'check pinb.4 waitms 25 'wait 25ms IF EVEN THE SLIGHTEST BUMP CAUSED PINB.4 TO EQUAL ZERO if pinb.4 = 0 then 'check pinb.4 again led = 1 ' if button was held down at least 25 continuous ms then turn led on end if end if loop

BASCOM-AVR : Need debounce help : REPLY

$
0
0
I have revised my code to: do If Pinb.4 = 0 Then waitms 2 incr sbounce If sbounce > = 28 Then ' 'do stuff because with has been held at least 56ms End If If pinb.4 =1 then ' button has been released before count is up sbounce = 0 'reset sbounce ' do different stuff while switch is open end if loop

BASCOM-AVR : Fast ADC in free mode : NEWTOPIC

$
0
0
Two days I´m reading forum and trying make it working but without success. I think I really mismatched myself. I need to read ADC occasionally but without interrupt or delay. I cannot configure ADC to free mode and simply read ADCL and ADCH from more channels. [code:1:00a3ab2288]$regfile = "m328pdef.dat" $crystal = 20000000 $hwstack = 64 $swstack = 48 $framesize = 48 Config Adc = Single , Prescaler = Auto , Reference = Avcc Admux = 0 Adcsra.aden = 1 Dim Adcvalue As Word , Adclow As Byte At Adcvalue Overlay , Adchigh As Byte At Adcvalue + 1 Overlay do Admux = 5 Adclow = Adcl Adchigh = Adch 'then do something with adcvalue from adc5 Admux = 3 Adclow = Adcl Adchigh = Adch 'then do something with adcvalue from adc3 loop [/code:1:00a3ab2288] This is not working, I´m really tired and cycled myself :( Thanks for any help [b:00a3ab2288][color=red:00a3ab2288](BASCOM-AVR version : 2.0.7.8 )[/b:00a3ab2288][/color:00a3ab2288]

BASCOM-AVR : Fast ADC in free mode : REPLY

$
0
0
There are examples in the BASCOM "Samples" directory. For instance, look for "adc.bas". That works.

BASCOM-AVR : Need debounce help : REPLY

$
0
0
What is bounce? when we have a digital switch we get proper 0 and 1. But an analog switch, and there are many different kinds so i take a simple push button, have a spring and 2 contacts. when you press the button, you press the spring and close the contact. if you let go the switch, the spring will push the button back. and the contacts bounce on/off very quick. this we can only measure with a microprocessor. Normal circuits like light switch do not care. So if we want to debounce, we mean that we want to detect the first switch, but not the bounce of the contacts. So a small delay, in which time the bounce occurs, is sufficient. Then after the wait we check again the state. If you check the state during the debounce, the purpose is defeated since you would react on the bounce. If you want to check how long somebody is keeping a button pressed, there is other logic. I do advise to test with real hardware. there might be 1001 variations, but best to keep it simple. Also consider the fact that during the waitms, the processor is only waiting and not doing something else. It is good practice to have a pull up resistor. The internal one is sufficient in most cases. turn it on by setting port register to 1. config pinb.4=input : portb.4=1 'pull up

BASCOM-AVR : TSA5511 PLL High and Low Byte calculation : REPLY

$
0
0
Hello :D When You type something for search in google then add magic word "bascom" I found code and solution in "~ 7 730 matches (0,28 s)" :D There is only 5 bytes to send . First address, then two bytes Hi and Lo of Word value. Two next bytes are almost constatnt. They are some settings for chip. In attachment first code I found but there is many more.. Have a nice day :D

BASCOM-AVR : Is the Assembler 'sleep' command the same as BASCOM Powerdo : REPLY

$
0
0
Sorry, i had the wrong PDF open. Laboratte is right. The P(A) indeed supports this for some of the sleep modes. it is probably a good idea to add this option.

Share your working BASCOM-AVR code here : LinkSprite UART Camera and a TinySine SIM900 GSM/GPRS Module : REPLY

$
0
0
Thanks for sharing your code. Nice solution with the 74LS125. Never thought about that. When you want to attach files, you can best ZIP the files. That is allowed. It is also a good container to store all relevant info.

BASCOM-AVR : Is the Assembler 'sleep' command the same as BASCOM Powerdo : REPLY

$
0
0
Thanks for the confirmation Mark. Have a wonderful evening! Tim

Share your working BASCOM-AVR code here : ILI9341 with SW/HW SPI, 8/16 Bit parallel mode : REPLY

$
0
0
Hi, try modifying line 425 to: [code:1:963333f497]Config Lcd_backlight_timer = Pwm , Prescale = 8 , Pwm = On , Compare_pwm = Clear_up[/code:1:963333f497] and line 435: [code:1:963333f497]Compare2a = Value[/code:1:963333f497] Here I have no errors: [code:1:963333f497]$regfile = "m328def.dat" $crystal = 16000000 $hwstack = 128 $swstack = 128 $framesize = 128 Config Submode = New Const False = 0 Const True = 1 Const Lcd_enable_backlight_pwm = True $include "ILI9341.inc" Lcd_init[/code:1:963333f497] Per default Timer2 is used as PWM timer. You can change it with: [code:1:963333f497]Lcd_backlight_timer Alias Timer0 ' or Timer1 [/code:1:963333f497] above the $include statement. Maybe you have to adjust the Config and the value settings according to the target controller. I admit I did'nt spend very much time on the ATMega compatibility, thank you for testing and reporting this! br

BASCOM-AVR : TSA5511 PLL High and Low Byte calculation : REPLY

$
0
0
Hi pd5dj Here is my old code for pll U6205B SP5055 TSA5055/5011 simple setup via 3 buttons for freq easy to change in code for other use cant remember if I used 4Mhz or 3.2Mhz for this [code:1:ead83ca346]'SP5055 TSA5055 / 5011 works OK Pll = Freq * 8 PLL lock ok 'U6205B work Pll = Freq * 16 PLL lock 'datasheet links 'SP5055 http://f5ad.free.fr/Docs_Composants/SP5055.pdf 'U6205B http://datasheets.weeqoo.com/U62/U6205B.pdf 'SDA SCL pullup 10K ohm +5V $regfile = "ATtiny45.DAT" $crystal = 4000000 $hwstack = 24 $swstack = 16 $framesize = 32 Config Portb.1 = Input Config Portb.4 = Input Config Portb.3 = Input Portb.1 = 1 Portb.4 = 1 Portb.3 = 1 Config Sda = Portb.0 Config Scl = Portb.2 Dim K As Byte Dim Snd_bytes As Byte Dim Ax(4)as Byte Dim A As Byte Dim Pll As Word Dim Pll_lsb As Byte Dim Pll_msb As Byte Dim Freq As Word Dim Frq As Word Dim Address_write As Byte , Charge_pump As Byte , Control_bit As Byte Dim Sel_pll As Byte , Pll_lock As Byte Address_write = &HC2 Const Address_read = &HC3 Charge_pump = &H8E Control_bit = &H00 'Set start frq to 1250Mhz Freq = 1250 A = 1 'sel_pll = 0 > U6205B 'sel_pll = 1 > SP5055 Sel_pll = 1 Do 'if we change frq via buttons go here (1250 - 1270 - 1280 - 1290 Mhz) If A = 1 Then A = 0 If Sel_pll = 0 Then Pll = Freq * 16 'U6205 If Sel_pll = 1 Then Pll = Freq * 8 'SP5055 TSA5055/5011 Pll_msb = High(pll) Pll_lsb = Low(pll) Ax(1) = Pll_msb Ax(2) = Pll_lsb Ax(3) = Charge_pump 'Ax(4) = Control_bit 'if ax(4) enable then Snd_bytes = 4 default is 00 Snd_bytes = 3 I2csend Address_write , Ax(1) , Snd_bytes If Sel_pll = 1 Then Waitms 100 I2creceive Address_read , Pll_lock Waitms 100 If Pll_lock = 1 Then Lcd "PLL locked" Else Lcd "PLL unlocked" End If End If End If If Pinb.1 = 0 Then Freq = 1280 '1280 Mhz 1280/0.125 A = 1 Bitwait Pinb.1 , Set 'wait until key relase End If If Pinb.4 = 0 Then Freq = 1270 '1270 Mhz A = 1 Bitwait Pinb.4 , Set 'wait until key relase End If If Pinb.3 = 0 Then Freq = 1290 '1290 Mhz A = 1 Bitwait Pinb.3 , Set 'wait until key relase End If Waitms 100 Loop[/code:1:ead83ca346]

BASCOM-AVR : Fast ADC in free mode : REPLY

$
0
0
Thanks for answer but it is not what I want. "adc.bas" works in single mode (slow), "adc_int.bas" works in free mode but using interrupt. What I need is ADC in free mode without interrupts and without waiting for end of conversion. I think here [url]http://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=9374&highlight=adc+free[/url] is what I need: [quote:543a2449ef]the big advantage of free mode is, that the ADC samples in the background instead having you waiting for end of conversion. Nobody tells you have to use free running with ADC interrupt :) You can have it free running and simply read out the least current result., whenever you like. It only costs the time then to read out ADCH, which will be less than 1µs. However all depends on your requirements, whether for example the least current result is good enough, or if the result has to be read at an exact specified time in your code. If you use a prescaler of 16, then it takes 16 * 13 cycles for each conversion, that's 208 cycles, and that's 11.3µs which corresponds pretty well with your 12.5µs. If you wait for it, it blocks your code for that time. In case you do a series of samples, you won't get any faster either, as that's simply the ADC limits. Only if at some time in your code you need a result as fast as possible, then simply reading out ADCH in free running mode could do. [/quote:543a2449ef] But I cannot reach this :(

BASCOM-AVR : TSA5511 PLL High and Low Byte calculation : REPLY

$
0
0
Hi Kimmi Thanks for the usefull answer :) And good to hear from you again,, (maybe 10 days too late, but happy birthday) I tried to contact you via Skype, do you still use it? About the code: In the mean time I have figured out lots myself, and got a good working code last night.. In fact it looks a lot like your aproach. Anyways thanks for example :)

BASCOM-AVR : Fast ADC in free mode : REPLY

$
0
0
[quote:bef8a09911="Ruprecht"]But I cannot reach this :([/quote:bef8a09911] Because you lack basic understanding how free-run works. Also in free-run there's a conversion time, the same as in single mode, so after changing the channel one still has to wait till the conversion is ready. So this [code:1:bef8a09911] Admux = 5 Adclow = Adcl Adchigh = Adch [/code:1:bef8a09911] is complete nonsense. As more as it kills partly this line: [code:1:bef8a09911]Config Adc = Free , Prescaler = Auto , Reference = Avcc[/code:1:bef8a09911] by clearing REFS0 and setting Reference to external. To do free-run mode without ISR is much more complex, if more than one channel is involved. If you would consult the data sheet [quote:bef8a09911]In Free Running mode, always select the channel before starting the first conversion. The chan- nel selection may be changed one ADC clock cycle after writing one to ADSC. However, the simplest method is to wait for the first conversion to complete, and then change the channel selection. Since the next conversion has already started automatically, the next result will reflect the previous channel selection. Subsequent conversions will reflect the new channel selection.[/quote:bef8a09911] you'd learn that it depends on when the main-loop is able to read ADC. The problem is asynchronous handling of the result in the main loop, it's difficult to say to what MUX-setting the result belongs to. If the time between setting MUX and reading ADC is longer than two ADC-conversions, the result always belongs to the actual MUX-setting, otherwise it may belong to the previous setting. That is also the reason, you'll find little information for your approach [quote:bef8a09911]What I need is ADC in free mode without interrupts and without waiting for end of conversion.[/quote:bef8a09911] as it's unsuitable, if you need to switch channels. In an ISR the MUX-switching can be done in a controlled way, considered the ADC-ISR is not blocked by other ISR for too long. Then simply the actual result belongs to the previous MUX-setting. However, if free run is done with only one channel (like in the link you've posted), the problem doesn't occur, one simply reads ADC and always gets the last valid result. With repeatedly changing MUX, it's much different. Better describe what you want to achieve and why without ISR, than describing an unsuitable approach.

BASCOM-AVR : Fast ADC in free mode : REPLY

$
0
0
Have you tried change "single" to free in adc.bas? In Attiny841 I use [code:1:f9cf63c633]Admuxa = &B0010_1011' Differential Adcsra = &B1111_0101' 'Auto Trigger enable (Bit5) Adcsrb = 0 'Free Running mode W1 = Adc If W1.9 = 1 Then W1 = W1 Or &HFE00 'for negative values [/code:1:f9cf63c633] No interrupts.

BASCOM-AVR : A problem with glcdks108.lbx Library : NEWTOPIC

$
0
0
Hi every one. It seems there is a problem with using GLCD KS108 SED 12864 and "glcdks108.lbx" Library in BASCOM-AVR (Ver. 2.0.7.6) . When I try to send some characters to GLCD by using Lcdat y , x command, If I use it as Lcdat 1 , 1 , ... there is no problem, but when I use it as Lcdat 1 , 0 , ... the entire right half of display, going 1 pixel down ! (As you can see below) [img:cd522c43f7]http://s6.picofile.com/file/8185000134/12864_lcd.jpg[/img:cd522c43f7] also there is some another similar problem reports in net forums like this post in a polish website: [url=http://www.elektroda.pl/rtvforum/topic2195851.html]Link[/url] meanwhile I see same problem with left to right language texts for e.g. Persian(Font8x8): [img:cd522c43f7]http://s6.picofile.com/file/8185207742/A_Problem_with_GLCD_KS108_12864.jpg[/img:cd522c43f7] Many thanks Masih [b:cd522c43f7][color=red:cd522c43f7](BASCOM-AVR version : 2.0.7.6 , Latest : 2.0.7.8 )[/b:cd522c43f7][/color:cd522c43f7]

BASCOM-8051 : need help with counter : REPLY

$
0
0
You are shure, that you don't have problems with hardware. It is more "find the 7 errors". Also the drawing is not the gold winning award.

Share your working BASCOM-AVR code here : Fast library for SSD1963 LCD : REPLY

$
0
0
Hello How do we draw the part of the circle (arc) to SSD1289 Please "

BASCOM-AVR : Need debounce help : REPLY

$
0
0
use config debounce . see bascom avr help

Share your working BASCOM-AVR code here : Fast library for SSD1963 LCD : REPLY

$
0
0
http://bascom-forum.de/showthread.php?4328-SSD1289-Display-3-2-Zoll-240x320-mit-XMEGA128A1 Do a search in this forum. And you are in the wrong section. This is the share your code section. Ben Zijlstra
Viewing all 20563 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>