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

BASCOM-AVR : 10-bit ADC, bipolar : REPLY

$
0
0
Meister, Bascom does two conversions per GETADC. You can change it to one conversion by editing out the second conversion in the mcs.lib and recompiling in TOOLS, LIB MANAGER. Select the edited mcs.lib and compile. Exit with OK. Check if it looks like this: [_GETADC] _GetADC: * Sbi ADCSR,6 ; start conversion _GetADC_1: * Sbic ADCSR,6 ; skip next instruction if ready Rjmp _GetADC_1 ; not ready ;--- remark the next 4 lines for single conversion ;* Sbi ADCSR,6 ; we need 2 conversions for a good result ;_GetADC_2: ;* Sbic ADCSR,6 ; skip next instruction if ready ; Rjmp _GetADC_2 ; not ready ;------------------------------------------------- * In r24,ADCL ; first read lower data register * In r25,ADCH ;then read upper data register Ret [END] --------------------- Do not forget to safe mcs.lib and mcs.lbx under an other name or directory before editing. You might also try to increase the ADC-clock up to 1 MHz with manual prescaler. This will increase error by approx. 1-2 LSB. Do not forget to insert one dummy GETADC after bootup. The mcs.lib procedure was discussed quite some time ago. Good luck. Hubert

BASCOM-AVR : 10-bit ADC, bipolar : REPLY

$
0
0
[quote:131a18397b="Meister"]At present I try to eliminate residual [i:131a18397b]periodic [/i:131a18397b]~1MHz "noise" by averaging many ADC readings - with disappointing results.[/quote:131a18397b] To measure a much faster signal with a much slower ADC will not work, a better way is to do some hardware-filtering. [quote:131a18397b]Maybe single conversion will do better in this case. I will try.[/quote:131a18397b] At least samples are taken then more periodically, as compared with freerun and unsync'd fetch of the ADC-result. Likely it will fail also, as the first statement still applies. You'd be much better off, if you don't describe your failed experiments, but the problem as whole.

BASCOM-AVR : 10-bit ADC, bipolar : REPLY

$
0
0
Thanks to everybody, @MWS: The ~1-2 MHz periodic noise is the remainder of a clock signal generated by Timer0 in CTC mode, fed into some external hardware and measuring the outcome by the ADC after RC-filtering (I can't show the whole project). Damping the signal by heavier filtering appears to be not the best since any change in the filter would have to be done by soldering... I will try now to trigger the ADC by "Timer/Counter0 Compare Match A". If the sample-and-hold circuit charges up during the full time determined by the prescaler, that should take care of the noise in one ADC shot, hopefully. I have to play now with the registers (not using config ADC). Would you consider that as a useful method?

BASCOM-AVR : XMega USB Support : REPLY

$
0
0
Hi, that would interest me too. Any news ? Kind Regards Kay

BASCOM-AVR : 10-bit ADC, bipolar : REPLY

$
0
0
[quote:0b321d7b21="Meister"]Would you consider that as a useful method?[/quote:0b321d7b21] A good sniper would shoot between two heartbeats ;-) But you have a problem, if the heartbeat is faster than the bullet. Also, did you read this? [quote:0b321d7b21]Differential Gain Channels ... The gain stage is optimized for a bandwidth of 4 kHz at all gain settings. Higher frequencies may be subjected to non-linear amplification.[/quote:0b321d7b21] It's not a big deal to try it out. Hm, the CTC clock itself is not at 1MhZ, isn't it? As then I would wonder, how the ADC behaves, if it is triggered faster, than it can do a conversion.

BASCOM-AVR : 10-bit ADC, bipolar : REPLY

$
0
0
MWS: You are right, with ADC bandwidth of 4kHz, the 1-2 MHz (adjustable) CTC -related signal (as seen by a differential, isolated Oscilloscope) should be far off from being detectable by the ADC... But there is fluctation in averaged ADC values transmitted each ~50ms. Since the MHz noise is the only one I see I conclude the fluctuation is related to that. [quote:fd700c903b]w=0 for i=1 to 128 w1=adc w=w+w1 next Shift w,right,5 'or more shifts [/quote:fd700c903b] Maybe that very fast averaging is nonsense since the 128 readings all might be the same due to the free running ADC. So I have reconsider the handling of the ADC in view of these discussions. [quote:fd700c903b]I would wonder how the ADC behaves, if it is triggered faster, than it can do a conversion.[/quote:fd700c903b] I think during a conversion further triggers are neglected. I think I have read that in the manual (Attiny841).

BASCOM-AVR : 10-bit ADC, bipolar : REPLY

$
0
0
I like to add that it is better to copy code from the lib and place it in your own lib. That way you only need to add $lib "your.lib" to your code and you dont need to worry that an update will overwrite your modifications. Since the compiler will search mcs.lib last, it will include code found in a user defined lib.

Share your working BASCOM-AVR code here : BASCOM syntax highlighting on website : NEWTOPIC

$
0
0
I read an article about regular expressions and modified the google code for the purpose of Bascom. If someone on your side presents the source code, and would like syntax highlighting, you can give the language file converted to look like on my website. Colors of defining separately of course you can yourself. Even the hardware are written in capital letters automatically. [url=http://bart-projects.cba.pl/if.html]Take of look, and other sub pages.[/url] The terms appends records as needed and gradually. Have a nice day.

Share your working BASCOM-AVR code here : Serial Framing : NEWTOPIC

$
0
0
I am working on a machine monitoring project and not sure how to solve it? An old multiplexer board is used to read one status byte from each of 32 machines. It switches in a loop continuously reading a byte from each machine and dwelling for 8 millisecond. it repeat the cycle continuously. The circuit stuffs data into a register and pumps it out the serial port at 1200 baud with proper byte framing (start bit, data, stop, etc). The problem to identify the start of the sequence, since each byte is not tagged with machine number. if I know the start, I count each byte and number them, but where is the beginning? I think I need a way to measure the dwell period and generate a start character? I know how to get data serial form the uart, but how can I reliably detect the dwell and frame the record with a start character? any tips or code suggestions would be a big help. I can't modify the original circuit, not allowed. thanks it appreciated.

BASCOM-AVR : Using SPI on 3.5 display with FTDI FT800 controller. : REPLY

$
0
0
Hello Peter, Do you have the latest code for the FT800 for me. I follow your discusions about the FT800 for a long time and i will try the code on a test board. Can you send me the code to info at jahuls-electronica dot nl Jaap

Share your working BASCOM-AVR code here : BASCOM syntax highlighting on website : REPLY

$
0
0
It looks great. Tthis is implemented in our wiki too. in fact,Tomi just implemented it for this forum too. when you use the code tags like : [code:1:0f68a04f1d]print "test"[/code:1:0f68a04f1d] the code will be highlighted. thanks for bringing this to my attention.

Share your working BASCOM-AVR code here : BASCOM syntax highlighting on website : REPLY

$
0
0
Problem is that I`m not programmist and my site is NOT in PHP for GESHi :lol: II spend whole evening to read and understand regular expressions. For JAVA only I found Prettyfy. This is link to Google Drive if anyone want to test It. In hardware section I must add words. I work on it couple of days but Im steel learning :D [url=https://drive.google.com/file/d/0ByTGnTHgAjlzSlFXa2FieGY0Z2s/edit?usp=sharing]Mooded for Bascom - only this is needed[/url]

Share your working BASCOM-AVR code here : Serial Framing : REPLY

$
0
0
rossfl, First, You should post questions like this in the Bascom-AVR form. This forum is for completed example code. No big deal though... It sounds like you are getting in 32 bytes of data at a rate slower then the 8ms and then a delay somewhere around 8ms. So here is what I would do but this is just an example and not real code. Here is some exaple code that might work but it should give you a starting point... -Glen [code:1:9f213a3e45] '=====[ Compiler Directives ]================================================== $crystal = 16000000 $regfile = "m328def.dat" $baud = 1200 '------------------------------------------------------------------------------ const DWELLTIME = 6 ' this time should be less then the 8ms but longer then the time between each normal byte received. const STABLEFRAMECOUNT = 3 ' minimum number of good frames before we try using the data... dim TickCount as byte ' this will host the number of ms between each byte and 250 if there is no data for 250ms or longer dim myData(32) as byte dim myDataindex as byte dim newByte as byte dim frameCount as byte ' holds the number of frames up to 100. its reset to 0 if there is no data for 100ms or more. dim frameCountOld as byte '=====[ Setup Timer0 for Tick isr ]============================================ Config Timer0= Timer, Prescale= 1024, Compare A= Disconnect, Clear Timer= 1 ' crystal / Prescale / Hz Wanted = reload value ' 16000000 / 64 / 1000 = 250 (1ms steps) OCR0A = 250 - 1 ' subtract 1 as per AVR docs On OC0A TickCounter0_isr Enable Timer0 '------------------------------------------------------------------------------ Enable Interrupts ' The main look starts here................. do if ISCHARWAITING() = 1 then Gosub ProcessNewData if frameCount <> frameCountOld then Gosub ProcessNewFrame loop ProcessNewData: TickCount= 0 ' reset the timer newByte = inkey() ' get the new data if TickCount > DWELLTIME then myDataIndex = 1 ' reset the index incr frameCount ' start of new frame else incr myDataIndex end if if myDataIndex < 33 myData(myDataIndex)= newByte ' load the data into the next position end if return ProcessNewFrame: if frameCount => STABLEFRAMECOUNT then ' ' we have a new frame and its stable! Now do something with it! :) ' end if if frameCount > 100 then frameCount = 100 frameCountOld= frameCount return '=====[ Timer ISR routine ]==================================================== TickCounter0_isr: Incr TickCount if TickCount > 100 then TickCount = 100 frameCount = 0 frameCountOld = 0 end if Return '------------------------------------------------------------------------------ [/code:1:9f213a3e45]

Share your working BASCOM-AVR code here : NOKIA-3310/5110 LCD library : REPLY

$
0
0
Please could somebody tell me where I can download the Nokia 3310/5110 lcd library?

Share your working BASCOM-AVR code here : NOKIA-3310/5110 LCD library : REPLY

$
0
0
In first post ..when You are logged in - no visible for no logged guest or visitors :)

Share your working BASCOM-AVR code here : Tektronix 4010(4014) graphic terminal (emulator) library : NEWTOPIC

$
0
0
Tektronix 4010 (4014) is a computer graphics terminal of an old time. Catalog: [url=http://archive.computerhistory.org/resources/text/Tektronix/Tektronix.Tektronix4010.1971.102646119.pdf]Tektronix 4010 Computer Display Terminal[/url] Terminal emulator software "Tera Term" has a TEK4010 (4014) terminal emulation function. BASCOM makes a graph draw to a personal computer using this function. It connects by "RS-232C" or "USB-serial conversion" using UART of AVR. Since the Arduino board carries "USB-serial conversion", the addition of an option is unnecessary. AVR obtains the display screen of high resolution, and acquires the capability to print(Hard copy) it with a printer! Computer screen [url=http://www.ne.jp/asahi/shared/o-family/ElecRoom/AVRMCOM/TEK4010/TEK4010gdispa.gif][img:efe6510cc8]http://www.ne.jp/asahi/shared/o-family/ElecRoom/AVRMCOM/TEK4010/TEK4010gdispas.jpg[/img:efe6510cc8][/url] Hard copy [url=http://www.ne.jp/asahi/shared/o-family/ElecRoom/AVRMCOM/TEK4010/TEK4010gdispb.jpg][img:efe6510cc8]http://www.ne.jp/asahi/shared/o-family/ElecRoom/AVRMCOM/TEK4010/TEK4010gdispbs.jpg[/img:efe6510cc8][/url] 1.Download and install the latest version of "[url=http://ttssh2.sourceforge.jp/index.html.en]Tera Term[/url]" from "SourceForge.jp". 2.[Setup] -> [Serial port] -> "Serial port setup" dialog box.Set the baud rate. 3.[Setup] -> [Terminal] -> "Terminal setup" dialog box. Enable the "Auto switch (VT<->TEK)". 4.[Control] -> [Open TEK] -> Opens the TEK window. [Setup] -> [Font] -> "Font" dialog box. Font size is changed into any value. (Example: Size 16) 5.[Setup] -> [Window] -> "Window setup" dialog box. The color of "Text" and "Background" is changeable. 6.[VT-window] -> Return to the "VT-window". [Setup] -> [Save setup] -> "Save setup" dialog box. Save the settings. [code:1:efe6510cc8] ' ' *************************************************** ' * Tektronix 4010(4014) Graphic Terminal Library * ' * O-Family 2014. 9.29 * ' *************************************************** ' $regfile = "m88pdef.dat" 'Any chip. $crystal = 16000000 'Any frequency. ' $hwstack = 64 $swstack = 32 $framesize = 24 $baud = 9600 'Set the baud rate. '--------- Include a control instruction of TEK4010. --------- Dim _temptx As Byte 'Internal variables of the library. _temptx = &H1F : Printbin _temptx '[US] Changes Terminal to Alpha Mode. $lib "TEK4010emu.lib" 'Tektronix 4010(4014) graphic terminal (emulator) library. $external Tekcls , Tekline , Tekbox , Tekpset , Teklocate , Tekgraph , Tekalpha , Tekplot Declare Sub Tekcls : Declare Sub Tekalpha : Declare Sub Teklocate(byval _tekx0 As Word , Byval _teky0 As Word) Declare Sub Tekline(byval _tekx0 As Word , Byval _teky0 As Word , Byval _tekx1 As Word , Byval _teky1 As Word , Byval _tekvt As Byte) Declare Sub Tekbox(byval _tekx0 As Word , Byval _teky0 As Word , Byval _tekx1 As Word , Byval _teky1 As Word , Byval _tekvt As Byte) Declare Sub Tekpset(byval _tekx0 As Word , Byval _teky0 As Word) Declare Sub Tekgraph(byval _tekvt As Byte) : Declare Sub Tekplot(byval _tekx0 As Word , Byval _teky0 As Word) ' ' Tekcls <Clear the Vector and Alpha Screen.> ' Tekline X(start) , Y(start) , X(end) , Y(end) , Vector-Type [X = 0 - 1023 , Y = 0 - 778 , Vector-Type = 0 - 23] <Draws a line.> ' [Vector-Type = 0:normal line , 1:dotted line , 2:dot-dashed , 3:short-dashed , 4:long-dashed] ' Tekbox X(left corner) , Y(top position) , X(right corner) , Y(bottom position) , Vector-Type <Write a box.> ' Tekpset X(location) , Y(location) [X = 0 - 1023 , Y = 0 - 778] <Set a single pixel.> ' Teklocate X(location) , Y(location) [X = 0 - 1023 , Y = 0 - 778] <Moves the Alpha cursor to the specified position.> ' Tekgraph Vector-Type [Vector-Type = 0 - 23] <Sets Terminal to Graph Mode , Select the vector type.> ' Tekplot X(location) , Y(location) [X = 0 - 1023 , Y = 0 - 778] <Plot the graph line.> Note: Perform Tekgraph. ' Tekalpha <Terminal is returned to alpha mode.> '------------------------------------------------------------- ' ************************ ' * Drawing test program * ' ************************ Dim W1 As Word , W2 As Word , W3 As Word , S1 As Single , S2 As Single , B As Byte Tekcls 'Clear the Vector and Alpha Screen. Print "Tektronix 4010(4014) graphic terminal (emulator)" Tekline 0 , 0 , 1023 , 0 , 1 'Outer frame. Tekline 1023 , 0 , 1023 , 778 , 1 Tekline 1023 , 778 , 0 , 778 , 1 Tekline 0 , 778 , 0 , 0 , 1 ' Tekline 0 , 430 , 1023 , 430 , 0 'Vector Type. Tekline 0 , 420 , 1023 , 420 , 1 Tekline 0 , 410 , 1023 , 410 , 2 Tekline 0 , 400 , 1023 , 400 , 3 Tekline 0 , 390 , 1023 , 390 , 5 ' Teklocate 900 , 388 'Moves the Alpha cursor. Print "Vector Type" For W1 = 448 To 778 Step 10 'Slanting line. Tekline 0 , 448 , 1023 , W1 , 0 Next W1 Tekbox 80 , 720 , 280 , 580 , 1 'Write a box. Tekbox 100 , 700 , 200 , 600 , 0 ' Teklocate 134 , 638 'Moves the Alpha cursor. Print "BOX" Tekline 30 , 195 , 390 , 195 , 1 'Scale line. Tekline 30 , 45 , 30 , 345 , 0 ' For W1 = 0 To 360 'Sign waveform. S1 = W1 S1 = Deg2rad(s1) S1 = Sin(s1) S1 = S1 * 150 S1 = S1 + 195 W2 = Int(s1) W3 = W1 + 30 Tekpset W3 , W2 'Set a single pixel. Next W1 ' Teklocate 240 , 270 'Moves the Alpha cursor. Print "Sign Wave" Tekline 450 , 195 , 710 , 195 , 3 'Scale line. Tekline 580 , 65 , 580 , 325 , 3 ' For W1 = 0 To 360 'Circle. S1 = W1 S1 = Deg2rad(s1) S2 = Cos(s1) S1 = Sin(s1) S1 = S1 * 120 S1 = S1 + 195 W2 = Int(s1) S2 = S2 * 120 S2 = S2 + 580 W3 = Int(s2) Tekpset W3 , W2 'Set a single pixel. Next W1 ' Teklocate 500 , 230 'Moves the Alpha cursor. Print "Circle" Tekline 770 , 80 , 1000 , 80 , 0 'Scale line. Tekline 770 , 80 , 770 , 310 , 0 ' Restore Graphdata 'Drawing a graph. W1 = 770 'X position. Tekgraph 1 'Sets Terminal to Graph Mode , Select the vector type. For B = 1 To 5 Read W2 Tekplot W1 , W2 'Plot the graph line. W1 = W1 + 50 Next B Tekalpha 'Terminal is returned to alpha mode. ' Teklocate 860 , 280 'Moves the Alpha cursor. Print "Graph" Teklocate 50 , 520 'Moves the Alpha cursor. Print "END" End Graphdata: Data 120% , 220% , 250% , 150% , 180% 'Graph data. [/code:1:efe6510cc8] Coordinate [img:efe6510cc8]http://www.ne.jp/asahi/o-family/extdisk/TEK4010/TEK4010gdispi_en.gif[/img:efe6510cc8] By changing a part of embedded program and library, software UART can also be used for AVR without UART. "Printbin" -> "Printbin #1"

BASCOM-AVR : Serial Framing : REPLY

$
0
0
Hi Glen: Wow thanks for this very detailed and clearly commented example. This pretty much nails it. I am waiting to connect to one of the multiplexers for testing. I will add to this example and let you know how it goes. thx a bunch this is a big help and greatly appreciated! thanks!

Share your working BASCOM-AVR code here : Tektronix 4010(4014) graphic terminal (emulator) library : REPLY

$
0
0
Hello O-Family, great nostalgic application :D It was nice to read the brochure. $3500 for a terminal, wow ! Your lib is a good example for a serial based display. Because of the emulator it is simple to try. Thanks for sharing.

BASCOM-AVR : Bug when using more than 64k Flash on ATMega 1284P : REPLY

$
0
0
Dear all, Mark spend a couple of time to find the problem. It was inside my code. I use the graphics fonts from Evert Dekker in the updated version from Mladen (runs 15-20% faster). This version uses loadlabel to load the used Fonts. The variable is declared as a word which does not contain the page adress. This is the point where the graphics on the lcd gets distorted. I will ask Evert / Mladen if they can fix this problem in their code. BR, Jens

Share your working BASCOM-AVR code here : Sorting Long variable type arrays : NEWTOPIC

$
0
0
I needed to sort an array of long variables but read in the help that " Sorting is implemented for byte, word and integer arrays. " So I set about writing one that works for all, It took me a while but I have it working. Regards Paul [code:1:d9be6f43a2] Sub Arraysort Local Al As Long Local I As Byte Local J As Byte For I = 2 To 9 'to highest element number of array Al = Onlongs(i) J = I While J > 1 And Onlongs(j -1) > Al Onlongs(j) = Onlongs(j - 1) J = J - 1 Wend Onlongs(j) = Al Next End Sub [/code:1:d9be6f43a2]
Viewing all 20567 articles
Browse latest View live


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