Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Need Help.Converting assembler to C

Status
Not open for further replies.

mtn1905

New Member
İ need help about this Circuit.i have to do this project.But i dont know anything about Assembler but my C knowladge is little good.Is there anybody can help me about this situation?

Because if i want to change something in circuit i have to know what's the meaning of code.But unfortunately i don't know assembler.

everything in file wich i uploaded to rapid.

thanks for help.



**broken link removed**
 

Attachments

  • isikontroldeneme1.asm
    10.5 KB · Views: 120
Last edited:
hi.im janani.im currently working on a robotics project,"MICROMOUSE MAZE SOLVING".i have used atmega16 microcontroller.along with this i have an lcd display unit and sensor.my lcd display is conected to portc 4-7.i need to read the adc outputs in my LCD display.since my adc is an 10 bit resolution,how do i access them in the four pins of portc.i dont get any apt c code to tranfer them.pls help
 
dude since it was your first post i dont think anyone is going to do your work for you. Also if you know C at any rate you can convert that in a matter of time.

C is easier than asm but it uses all the same stuff. From ASM to C should be easier than C to ASM.

All ASM is in datasheet.

I see alot of "BCF PORTC,RW"

Data sheet says BCF = Bit Clear (F)

Where F is the Regiter Bit. So clear PortC, RW in C would be

RW = 0;

and RW is defined as "RW EQU 0"

#define RW PORTCbits.RC0

The above examples work in C18
Thats all im going to help with just becuase i dont see any issue of why you cant do it yourself.

Sorry if im sounding mean but people come here expecting slaves.. aka free workers. Thats not the case with some but many. If you cant do this then you need to learn some ASM.

If you dont know how to use ASM in small parts at least to convert some of this then you learned to walk before you can crawl and oops! you just fell because you was not will to take it from the top.

Again no mean intent intended.
 
Thanks for all advices.i made some solutions about my work.
i wrote C codes but i need to know more. i want to connect 4x4 Numpad to enter set temperature.Like the example which i posted first and which made with assembler.

would you help me about it.


Code:
#include <pic.h>
#include <delay.c>
#include <lcd.c>
#include <stdio.h>

//----------------------------------------------------------
// eklenen kısım
//----------------------------------------------------------
#define mavi RB4
#define sari RB5
#define kirmizi RB6
#define dene RB7
//----------------------------------------------------------


main (void)
{
// Değişken tanımlamaları
const float lsb=5.0/1024.0;
unsigned char gerilim, ust, alt;
float sicaklik;
unsigned char sonuc[]="SICAKLIK = "; 
// Port konfigürasyonu
TRISB=0; // PORTB çıkış  
TRISA=1; // RA0 analog giris
// Ön LCD işlemleri
DelayMs(250); // 250ms bekle
lcd_init(); // LCD’yi hazırla 
lcd_clear(); // LCD'yi temizle
// ADC ayarları
ADCON1=0x8E; // AN0 analog giriş
ADCON0=0x41; // A/D aktif 

for(;;){
// A/D çevrimi başlat 
ADCON0=0x45; 
// Dönüşümün bitmesini bekle
while((ADCON0&4)!=0); 
// Dönüşüm sonucunu kaydet
gerilim=ADRESH; 
gerilim=256*gerilim+ADRESL;
// Sıcaklık bilgisini oluştur
sicaklik=gerilim*lsb*100.0; 
//----------------------------------------------------------
// eklenen kısım
//----------------------------------------------------------

if(sicaklik<20){ mavi=1; sari=0; kirmizi=0; dene=0;}
if(sicaklik>=20 && sicaklik<30){sari=1; mavi=0; kirmizi=0; dene=0;}
if(sicaklik>=30){kirmizi=1; sari=0; mavi=0; dene=1;}
//----------------------------------------------------------
// Tam ve ondalık kısımları ayır
ust=(int)sicaklik; 
alt=(int)(10.0*(sicaklik-ust)); 
// LCD’ye yazdırma işlemlerini yap
sprintf(sonuc+11,"%d.%dC ",ust,alt);
// 1. satıra geç ve LCD’ye yaz
lcd_goto(0x00); 
lcd_puts("LCD Termometre"); 
// 2. satıra geç ve sıcaklık değerini yaz
lcd_goto(0x40); 
lcd_puts(sonuc);  
// Biraz bekle ve ekranı temizle  
DelayMs(250); 
lcd_clear();
} // Ölçümü tekrarla
} // Programın sonu
 

Attachments

  • adsız.JPG
    adsız.JPG
    142 KB · Views: 174
Last edited:
I will help if you edit that above post and erase the code there and paste the code back into it using the code tag like below. Just remove the spaces from within the [] brackets. This way i and others can read the code better

[ code ] Code HERE[ /code ]
 
this is what i'm trying to do.

when the temperature below 20 degree blue led will be on.and motor is stop mode.

between 20 and 30 yellow will be turn on. when above 30 degree red led will be on and motor on too.

but there is something i want to add numpad..
click to star (*) enter a set temperature.if it is below from measured degree nothing gonna happen.but if it is above 5 degree motor will turn but if it measured degree is 10 or more degrees higher than set degree motor will turn more speedly.

i want to control speed of motor.
 

Attachments

  • xxx.JPG
    xxx.JPG
    156.8 KB · Views: 163
This looks nicer and more readable. Now i cant follow that language but ill try to help still.

Code:
#include <pic.h>
#include <delay.c>
#include <lcd.c>
#include <stdio.h>

//----------------------------------------------------------
// eklenen k?s?m
//----------------------------------------------------------
#define mavi RB4
#define sari RB5
#define kirmizi RB6
#define dene RB7
//----------------------------------------------------------


main (void)
{
                                                // Deg(is,ken tan?mlamalar?
    const float lsb=5.0/1024.0;
    unsigned char gerilim, ust, alt;
    float sicaklik;
    unsigned char sonuc[]="SICAKLIK = ";
                                                // Port konfigürasyonu
    TRISB=0;                                    // PORTB ç?k?s,
    TRISA=1;                                    // RA0 analog giris
                                                // Ön LCD is,lemleri
    DelayMs(250);                               // 250ms bekle
    lcd_init();                                 // LCD’yi haz?rla
    lcd_clear();                                // LCD'yi temizle
                                                // ADC ayarlar?
    ADCON1=0x8E;                                // AN0 analog giris,
    ADCON0=0x41;                                // A/D aktif

    for(;;){
                                                // A/D çevrimi bas,lat
        ADCON0=0x45;
                                                // Dönüs,ümün bitmesini bekle
        while((ADCON0&4)!=0);
                                                // Dönüs,üm sonucunu kaydet
        gerilim=ADRESH;
        gerilim=256*gerilim+ADRESL;
                                                // S?cakl?k bilgisini olus,tur
        sicaklik=gerilim*lsb*100.0;

//----------------------------------------------------------
// eklenen k?s?m
//----------------------------------------------------------

        if(sicaklik<20){ mavi=1; sari=0; kirmizi=0; dene=0;}
        if(sicaklik>=20 && sicaklik<30){sari=1; mavi=0; kirmizi=0; dene=0;}
        if(sicaklik>=30){kirmizi=1; sari=0; mavi=0; dene=1;}
//----------------------------------------------------------
// Tam ve ondal?k k?s?mlar? ay?r
//----------------------------------------------------------
        ust=(int)sicaklik;
        alt=(int)(10.0*(sicaklik-ust));
                                                // LCD’ye yazd?rma is,lemlerini yap
        sprintf(sonuc+11,"%d.%dC ",ust,alt);
                                                // 1. sat?ra geç ve LCD’ye yaz
        lcd_goto(0x00);
        lcd_puts("LCD Termometre");
                                                // 2. sat?ra geç ve s?cakl?k deg(erini yaz
        lcd_goto(0x40);
        lcd_puts(sonuc);
                                                // Biraz bekle ve ekran? temizle
        DelayMs(250);
        lcd_clear();
    }                                           // Ölçümü tekrarla
}                                               // Program?n sonu
 
This looks nicer and more readable. Now i cant follow that language but ill try to help still.
Code:
#include <pic.h>
#include <delay.c>
#include <lcd.c>
#include <stdio.h>

//----------------------------------------------------------
// eklenen k?s?m
//----------------------------------------------------------
#define mavi RB4
#define sari RB5
#define kirmizi RB6
#define dene RB7
//----------------------------------------------------------


main (void)
{
                                                // Variables
    const float lsb=5.0/1024.0;
    unsigned char gerilim, ust, alt;
    float sicaklik;
    unsigned char sonuc[]="SICAKLIK = ";  //sonuc variable of result Degree
                                                // Port configuration
    TRISB=0;                                    // PORTB is out
    TRISA=1;                                    // RA0 analog input
                                                // LCD Steps
    DelayMs(250);                               // wait 250ms 
    lcd_init();                                 // prepare LCD
    lcd_clear();                                // clean LCD
                                                // ADC settings
    ADCON1=0x8E;                                // AN0 analog input,
    ADCON0=0x41;                                // A/D activated

    for(;;){
                                                // A/D converting loop starts
        ADCON0=0x45;
                                                // wait until end of loop
        while((ADCON0&4)!=0);
                                                // store result of loop
        gerilim=ADRESH;                  //gerilim=Voltage
        gerilim=256*gerilim+ADRESL;
                                                // Calculate temperature 
        sicaklik=gerilim*lsb*100.0;    //sicaklik=Temperature

//----------------------------------------------------------
//----------------------------------------------------------
//mavi=(blue Led)
//sari=Yellow LEd
//kirmizi=Red Led
//dene=is for Motor output
        if(sicaklik<20){ mavi=1; sari=0; kirmizi=0; dene=0;}
        if(sicaklik>=20 && sicaklik<30){sari=1; mavi=0; kirmizi=0; dene=0;}
        if(sicaklik>=30){kirmizi=1; sari=0; mavi=0; dene=0;}
//----------------------------------------------------------
// Tam ve ondal?k k?s?mlar? ay?r
//----------------------------------------------------------
        ust=(int)sicaklik;
        alt=(int)(10.0*(sicaklik-ust));
                                                // Write to LCD
        sprintf(sonuc+11,"%d.%dC ",ust,alt);
                                                // write first line of LCD
        lcd_goto(0x00);
        lcd_puts("LCD Termometre");
                                                // Write sonuc to second line of LCD
        lcd_goto(0x40);
        lcd_puts(sonuc);
                                                // wait little then clean LCD
        DelayMs(250);
        lcd_clear();
    }                                           // Calculate again
}                                               // End of program
 
niCE! thanks ill try my best to help you out. Just give me some time. Its lunch.

but i was reading and what you want to do seems simple. I dont know anything about motor control but i can get you etup with the * to set temp and the testing of temp to the set temp and seperate functions depending on temp.(temp = temperature)
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top