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

BASCOM-AVR : FT800 : REPLY

$
0
0
FT800 only works with HW SPI ! It did not make any sense to me to use slow bit bang mode. But if you want it you can alter the lib and add some code to use soft spi.

BASCOM-AVR : Byte Variable = Byte Variable return error source and target : NEWTOPIC

$
0
0
Hello I need to set some bits in a byte and after send it. More precisely I need to set bit 7 of Byte_to_send. But I give back this: Error : 242 Line : 90 Data type of source and target variables do not match [ 0] , in File : E:Dropbox....FirmwareTest Comandi SingoliTest Comandi Singoli.bas What is wrong? Sub CC1101_Read_Value(ByVal Register_Address as Byte) Local Byte_to_send as Byte Local Received_Byte as Byte 'Costruisco il Byte da Inviare secondo la struttura '[7] := Header 1 '[6] := Burst 0 '[5-0] := Indirizzo Registro Byte_to_send = Register_Address SET Byte_da_Inviare.7 SPIout Byte_to_send,1 SPIin Received_Byte,1 Print "LETTO = "; Byte_Ricevuto End Sub [b:ec9fe96486][color=red:ec9fe96486](BASCOM-AVR version : 2.0.7.8 )[/b:ec9fe96486][/color:ec9fe96486]

BASCOM-AVR : Byte Variable = Byte Variable return error: source and targe : REPLY

$
0
0
Hi, This compiles fine with 2078. Give me a complete not working sample. With only the SUB it's hard to debug. [code:1:52fc6877b5] $regfile = "M88def.dat" $crystal = 8000000 $baud = 19200 $hwstack = 128 $swstack = 128 $framesize = 128 declare Sub CC1101_Read_Value(ByVal Register_Address as Byte) Dim A As Byte Config Spi = Soft , Din =Pinb.0 , Dout =Portb.1 , Ss =Portb.2 , Clock =Portb.3 Spiinit Do call CC1101_Read_Value(123) Loop End Sub CC1101_Read_Value(ByVal Register_Address as Byte) Local Byte_to_send as Byte Local Received_Byte as Byte 'Costruisco il Byte da Inviare secondo la struttura '[7] := Header 1 '[6] := Burst 0 '[5-0] := Indirizzo Registro Byte_to_send = Register_Address SET Byte_to_Send.7 SPIout Byte_to_send,1 SPIin Received_Byte,1 End Sub [/code:1:52fc6877b5]

BASCOM-AVR : Byte Variable = Byte Variable return error: source and targe : REPLY

$
0
0
'//////////////////////////////////////////// ' SPI SEND COMMAND '//////////////////////////////////////////// '********************************* 'Direttive al compilatore '********************************* $regfile = "m328pdef.dat" $hwstack = 32 $swstack = 32 $framesize = 32 $crystal = 16000000 $baud = 57600 '********************************* $Include "CC1101 REGISTER.inc" CONFIG SUBMODE = NEW CONFIG Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 16 SPIINIT Declare Sub CC1101_Init Declare Sub CC1101_Read_Value(byval Register As Byte) Declare Sub CC1101_Write_Value(byval Register As Byte , Byval Value As Byte) Declare Sub CC1101_Reset Dim Carattere_ASCII as Byte PRINT " -- TEST SPI COMMAND MENU --" PRINT "1) READ CONFIG REGISTER" PRINT "2) READ STATUS REGISTER" PRINT "" PRINT "" DO Carattere_ASCII = Inkey() 'get ascii value from serial port If Carattere_ASCII > 0 Then Print "ASCII = " ; Carattere_ASCII End If SELECT CASE Carattere_ASCII CASE 49 PRINT "READ CONFIG REGISTER" CC1101_Read_Value(&H0030) CASE 50 PRINT "READ STATUS REGISTER" CASE 51 CASE 52 END SELECT LOOP '_______________________________________________________________________________________ Sub CC1101_Init() End Sub '_______________________________________________________________________________________ Sub CC1101_Read_Value(ByVal Register_Address as Byte) Local Byte_to_Send as Byte Local Byte_Received as Byte Byte_to_Send = 0 Byte_Received = 0 'Costruisco il Byte da Inviare secondo la struttura '[7] := Header 1 '[6] := Burst 0 '[5-0] := Indirizzo Registro [b:777d75425d]Byte_to_Send = Register_Address [/b:777d75425d] SET Byte_to_Send .7 SPIout Byte_to_Send , 1 SPIin Byte_Received , 1 Print "BYTE READ = "; Byte_Received End Sub '_______________________________________________________________________________________ Sub CC1101_Write_Value(Register , Value ) End Sub '_______________________________________________________________________________________ Sub CC1101_Reset End Sub '_______________________________________________________________________________________

Share your working BASCOM-AVR code here : HTU21D temperature and humidity sensor 3V3 : REPLY

$
0
0
Hi Mark, If you compare the datasheets, The resolution and accuracy between the HTU21 and the SHT21 are equal. The HTU21 is a bit faster though. If i have time, i will make some measurements with both sensors.

BASCOM-AVR : Byte Variable = Byte Variable return error: source and targe : REPLY

$
0
0
you have : Declare Sub CC1101_Init Declare Sub CC1101_Read_Value(byval Register As Byte) Declare Sub CC1101_Write_Value(byval Register As Byte , Byval Value As Byte) Declare Sub CC1101_Reset and then check the implementation, it differs ! when using submode=new, you do not need the DECLARE , just put the sub/function before you call it, for example using an include file. when you do use declare sub, make sure the declare matches the implementation.

Share your working BASCOM-AVR code here : HTU21D temperature and humidity sensor 3V3 : REPLY

$
0
0
Hi beatkrik I also just made a SHT21 of program. Because I was calculating the CRC, please refer to. [code:1:ad5402013e] ' ' ********************************************** ' * SHT21 Temperature & Humidity sensor test * ' * O-Family 2015. 3.13 * ' ********************************************** ' $regfile = "m88pdef.dat" $crystal = 16000000 ' $hwstack = 64 $swstack = 10 $framesize = 24 Dim I2cbuff(20) As Byte Dim Sht21comsel As Byte Dim Temperature As Integer Dim Humidity As Integer ' Dim Tempw1 As Word Dim Templ1 As Long Dim Tempstr As String * 20 ' * LCD initialization * Config Lcdmode = Port Config Lcdbus = 4 Config Lcdpin = Pin , Db4 = Portb.3 , Db5 = Portb.2 Config Lcdpin = Pin , Db6 = Portb.1 , Db7 = Portb.0 Config Lcdpin = Pin , E = Portb.4 , Rs = Portb.5 Config Lcd = 16 * 2 ' Deflcdchar 0 , &H08 , &H14 , &H08 , &H06 , &H09 , &H08 , &H09 , &H06 Cursor Off Cls ' * I2C initialization * Config Scl = Portd.3 Config Sda = Portd.2 I2cinit Main: ' ' * Send the measure command to SHT21 * ' If Sht21comsel = 0 Then 'Temperature measurement? I2cbuff(5) = &B1111_0011 'Send the Temperature measurement trigger(no-hold) command. Sht21comsel = 1 Else I2cbuff(5) = &B1111_0101 'Send the Humidity measurement trigger(no-hold) command. Sht21comsel = 0 End If ' I2cstart I2cwbyte &H80 If Err <> 0 Then Goto Sht21error1 '[ACK] has not come back? I2cwbyte I2cbuff(5) Waitus 20 'no-hold waiting time.(20uS) I2cstop Waitms 100 'Waiting for measuring time. ' ' * Receive the measurement data from SHT21 * ' I2cstart I2cwbyte &H81 If Err <> 0 Then Goto Sht21error2 'Measurement is not finished? I2crbyte I2cbuff(1) , Ack 'Read the MSB data. I2crbyte I2cbuff(2) , Ack 'Read the LSB data. I2crbyte I2cbuff(3) , Nack 'Read the checksum. I2cstop ' Gosub Sht21crc 'Calculate the CRC8 for SHT21. If I2cbuff(3) <> I2cbuff(4) Then Goto Sht21error3 'CRC Error? ' ' * Display the measurement data to LCD * ' If I2cbuff(2).1 = 0 Then 'Temperature data? Locate 1 , 1 'Received data HEX display. Lcd Hex(i2cbuff(1)) ; Hex(i2cbuff(2)) ; Hex(i2cbuff(3)) ; " "; ' I2cbuff(2) = I2cbuff(2) And &B1111_1100 'Mask the status bit. Tempw1 = Makeint(i2cbuff(2) , I2cbuff(1)) 'Convert the 2-byte to one word. Templ1 = 17572 * Tempw1 'Calculation of temperature conversion. Temperature = Highw(templ1) '1/2^16 Temperature = -4685 + Temperature Tempstr = Str(temperature) If Temperature < 0 Then 'Negative value? Lcd Format(tempstr , " 0.00") ; " " ; Chr(0) Else Lcd Format(tempstr , " 0.00") ; " " ; Chr(0) End If Else 'Case of humidity data. Locate 2 , 1 'Received data HEX display. Lcd Hex(i2cbuff(1)) ; Hex(i2cbuff(2)) ; Hex(i2cbuff(3)) ; " "; ' I2cbuff(2) = I2cbuff(2) And &B1111_0000 'Mask the status bit. Tempw1 = Makeint(i2cbuff(2) , I2cbuff(1)) 'Convert the 2-byte to one word. Templ1 = 12500 * Tempw1 'Calculation of humidity conversion. Humidity = Highw(templ1) '1/2^16 Humidity = -600 + Humidity Tempstr = Str(humidity) Lcd Format(tempstr , " 0.00") ; " %" End If ' Main1: Waitms 900 'Waiting time of 1 second cycle. Goto Main ' ' * SHT21 Error (ACK is not returned) * ' Sht21error1: Locate 2 , 1 Lcd "#SHT21 ACK Error" Goto Main1 ' ' * SHT21 Error (Has not been completed measurement) * ' Sht21error2: I2cstop Locate 2 , 1 Lcd "#SHT21 NACK Ret." Goto Main1 ' ' * SHT21 Error (CRC Error) * ' Sht21error3: Locate 2 , 1 Lcd "#SHT21 CRC Error" ' Locate 1 , 1 Lcd Hex(i2cbuff(1)) ; Hex(i2cbuff(2)) ; Hex(i2cbuff(3)) ; ":" ; Hex(i2cbuff(4)) ; Spc(7) Goto Main1 ' ' * Calculate the CRC8 for SHT21 * ' Sht21crc: Loadadr I2cbuff(1) , Z $asm LDI R16,$02 'Number of bytes to calculate. CLR R24 'CRC value. LDI R22,$31 'POLYNOMIAL = 0x131 P(x)=x^8+x^5+x^4+1 = 1_0011_0001 Sht21crc1: LD R25,Z+ 'To read the calculated byte. EOR R24,R25 'CRC = CRC EXOR I2cbuff(x) LDI R17,$08 Sht21crc2: LSL R24 'CRC to the left I 1bit shift. BRcc Sht21crc3 'bit7 of shift before the CRC [1]? EOR R24,R22 'CRC = CRC EXOR &H31 Sht21crc3: DEC R17 BRNE Sht21crc2 '8-bit or end? DEC R16 BRNE Sht21crc1 'Number of bytes to calculate is over? ADIW R30,1 'Stores the calculated CRC value for the next received byte CRC. ST Z,R24 $end Asm Return ' ' End [/code:1:ad5402013e]

BASCOM-AVR : ESP8266 WIFI to serial board gets NTP time : REPLY

$
0
0
I want to try this program on my xm256a3b board. Here are the program's first some rows: [code:1:1ba3423dc5]$regfile = "xm256a3bdef.dat" $crystal = 32000000 $hwstack = 64 $swstack = 40 $framesize = 40 $lib "xmega.lib" $lib "i2c_twi.lbx" ' $external _xmegafix_clear $external _xmegafix_rol_r1014 Config Osc = Enabled , 32mhzosc = Enabled , 32khzosc = Enabled Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1 Config Clock = Soft , Rtc = 1KHZ_INT32KHZ_ULP , gosub = sectic Config Priority = Static , Vector = Application , Lo = Enabled Enable Interrupts Dim Sec_to_ntp_update As Integer[/code:1:1ba3423dc5] I receive many error messages after compiling the program. These errors show signs of one single row: config clock = soft, rtc = 1KHZ_INT32KHZ_ULP, gosub = sectic What's wrong?

BASCOM-AVR : ESP8266 WIFI to serial board gets NTP time : REPLY

$
0
0
There is a item in the wiki. 7 inch display using i2c.

BASCOM-AVR : Debugging in AVR Studio : REPLY

$
0
0
why anybody don't work to how we can use obj file in as4 with full variable watch? i realy want to go learc c languge because of this. please help Mark.

BASCOM-AVR : Debugging in AVR Studio : REPLY

$
0
0
[quote:a159a76e07="ghorban_pirizad"]why anybody don't work to how we can use obj file in as4 with full variable watch[/quote:a159a76e07] Bascom supports its own simulator, so support of another software can't be the goal. That it is done anyway in a certain amount can be seen as a bonus. [quote:a159a76e07]i realy want to go learn gcc languge because of this.[/quote:a159a76e07] Never had any problem to look up the address in Bascom and watch the changes in a AVR-Studio memory window. If this already shows to be a problem for you, you will likely fail in gcc.

BASCOM-AVR : Debugging in AVR Studio : REPLY

$
0
0
[quote:f897bb2965="MWS"][quote:f897bb2965="ghorban_pirizad"]why anybody don't work to how we can use obj file in as4 with full variable watch[/quote:f897bb2965] Bascom supports its own simulator, so support of another software can't be the goal. That it is done anyway in a certain amount can be seen as a bonus. [quote:f897bb2965]i realy want to go learn gcc languge because of this.[/quote:f897bb2965] Never had any problem to look up the address in Bascom and watch the changes in a AVR-Studio memory window. If this already shows to be a problem for you, you will likely fail in gcc.[/quote:f897bb2965] but problem here when we hav many var and alot of them isn't byte... how ISIS work perfect whith bascom obj file?!! is it possible to use this method in as4 ? or work on Laborratte AVRmapbuilder to fix that,s issu on non byte val? thank's alot.

BASCOM-AVR : 12 Volt Car battery charger with ADC : REPLY

$
0
0
Hi Rafael_jimenez, I agree with the others whe they say do the minimum abount possible sutch as set a flag and do the rest in the main loop. A couple of things with battery chargers, 1) Turn [b:960d0077d2]OFF [/b:960d0077d2]the charging voltage[b:960d0077d2] Before[/b:960d0077d2] measuring the battery voltage else you will only be reading the charge voltage and the program will terminate the charge too early. 2) You don't mention what type of battery you are charging. NiMh, NiCd, SLA, LiIo all have different charging patterns. 3) I really would like to see the battery that requires charging anywhere from [quote:960d0077d2]'** Battery 68Ah 560A. [/quote:960d0077d2]. Quite a battery. Submarine battery maybe? 4) After the [quote:960d0077d2]For A = 1 To 15 Valueadc = Valueadc + Getadc(6) Next A [/quote:960d0077d2] you should do a" Valueadc /15" to average the number out, and to deal with smaller numbers. Not strickly necessary but thats what I would do. 5) what is your ADC reference voltage set to ? 6) Your voltage divider needs looking at. If you say [quote:960d0077d2]Ground 5K6 >>>Pot 10K<<<< 100K Resistor to 12V + Battery [/quote:960d0077d2] The using the calculator at this site, http://www.raltron.com/cust/tools/voltage_divider.asp Then when the pot is at the uppermost voltage to the ADC is 0.6V Input Voltage 12V R1 100000r R2 5600r Output Voltage 0.636V When the input voltage is 1V the output to the ADC is 0.053V These voltages to the ADC are too low. The ADC measures voltages from 0v to 5V

BASCOM-AVR : Debugging in AVR Studio : REPLY

$
0
0
As you could read a page before, the simulator from Proteus actively supports Bascom's dbg-file, if you project that on AVR-Studio, Atmel needs to be convinced to support it. And for fixing anything on Laborrratte's tool, you have to address him to check, whether he's willing to do it or share his sources, so you can comit yourself. Or maybe start new from scratch, required info seems available, so it rather a matter of putting some serious time in. And as you ask, you can be the one to do the heavy lifting ;-)

BASCOM-AVR : 12 Volt Car battery charger with ADC : REPLY

$
0
0
Hello Deanus, Thank you for you answer, My Battery is for Car, GigaWatt Calcium Technology and form manufacturer say need Constant 14,40 volt, my Adjustable constant Power Supply is from 0Volt to 15Volt 4Amp I do so For A = 1 To 15 Valueadc = Valueadc + Getadc(6) Next A for better unit resultad, Sorry, perhaps ye not understand my explanation, I use 2 Resistor and one Potentiometer in my Resistor dividir to Adjust the correct ADC Value for Battery and looking so, GND<5K6> (to 10K Potentiometer here to adc(6) <100> to Battery Plus please See Schematic circuit. My code prepare for one Attiny45 with Led charging control. My code it works, but only I nedd when Battery is to 14,40 Volt Switch Off and Waiting when Battery voltage come down to 12,30 Volt, my Code doe Hystery and continuous loading all, I need a solution, when the battery is charged burdens stop and wait until it is depleted I am no to much experiencie with bascom , I am I am an electrician :P Thank you for you help Regards

BASCOM-AVR : Pset to Line : NEWTOPIC

$
0
0
Does someone have tip how to join two pixels X1 and X2 with some pixels between (not line) in this code (now is between two pixels empty space)? For an example, if is Y1=10 and next randome Y2=20, between is empty line (space), but it should be solid, filled with pixels... I was tried to use in code this math Y = Y1 +((y2 - Y1) /(x2 - X1)) *(x - X1) , but 2.0.7.8 BASCOM write an error "Data type of souorce and target variables does not match"..... X,Y are words...probably I use wrong sintax.. :roll: [code:1:417ccd20fd] 'basic loop Do For X = 0 To 64 Y = Some_random_value '0-2000 Y = Y / 8 Y = 32 - Y Pset X , Y , 255 Loop [/code:1:417ccd20fd] Tnx [b:417ccd20fd][color=red:417ccd20fd](BASCOM-AVR version : 2.0.7.8 )[/b:417ccd20fd][/color:417ccd20fd]

BASCOM-AVR : Pset to Line : REPLY

$
0
0
you should be able to mod something from here.. http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm copied from above. plotLine(x0,y0, x1,y1) dx=x1-x0 dy=y1-y0 D = 2*dy - dx plot(x0,y0) y=y0 for x from x0+1 to x1 if D > 0 y = y+1 'maybe just randomise whether x,y are plotted here????? plot(x,y) D = D + (2*dy-2*dx) else plot(x,y) D = D + (2*dy)

BASCOM-AVR : 12 Volt Car battery charger with ADC : REPLY

$
0
0
This example show simple logic. You can set "name" for constans for better code readable and then use simple "state of unit mechanism" State of unit You can change in any part/ place of code (witch switch or soeme value) and then in next loop another part of code will be run. [code:1:1dbb0efdf7] Dim Status As Byte Const Unknown = 0 Const Charging = 1 Const Discharging = 2 '### program START ### Do 'this is only example to show logic Valueadc = Getadc(6) Select Case Status 'after Boot Case Unknown Select Case Valueadc Case 0 To 11.0 V ' insert Your calculated value Home : Lcd "No battery " Case 11.1 To 14 , 3 V Home : Lcd "Charging... " Status = Charging Set Relay Case 14 , 4 To 15 , 3 V Home : Lcd "Battery Full" Status = Dicharging End Select 'end select voltage after boot 'if unit charging battery Case Charging Select Case Valueadc Case 0 To 11.0 V 'shortcut protection Reset Relay Status = Unknown Case 14 , 4 To 15 , 3 Home : Lcd "Battery Full" Status = Dicharging End Select 'end select when charging Case Discharging Select Case Valueadc Case 12.2 V To 12 , 4 V Home : Lcd "Charging... " Status = Charging Set Relay End Select 'end select when waiting for discharge End Select 'end select STATUS Wait 1 Loop End '### END ### [/code:1:1dbb0efdf7]

Share your working BASCOM-AVR code here : HTU21D temperature and humidity sensor 3V3 : REPLY

$
0
0
Thank's O-Family I wil try to implement your CRC code in my program. Great work !

BASCOM-AVR : 12 Volt Car battery charger with ADC : REPLY

$
0
0
Hello, I take this post to try to know how to properly do the evaluation of the percentage of the autonomy of a Litium battery. I think that when we are measuring the voltage it must will have to be injected a load to the battery. Will my reasoning correct? Best regards P_Santos
Viewing all 20688 articles
Browse latest View live


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