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.

Computer Language Discussion + PIC Programmers

Status
Not open for further replies.
Yes, it is a piece of old equipment that has been obsoleted. If someone understood that and wanted it as a collector's item or for its limited usefulness, I would sell it to them. I have no ethical issue with that.

I would not want to sell it to someone who did not understand that limitation.
...

Thanks for explaining, that makes good sense. :) I thought for a minute you may have been stating there was a licensing issue or something, please pardon my confusion.

...
Now, if you want to make a reasonable offer, it is all yours. :D
...

Well actually I have one as part of a rig for production programming (has been for many years) but due to all the wear and tear the ZIF socket is getting a bit sad. If you PM me with its firmware version number (you can display that in MPLAB) and if it's a late firmware and the price is decent I will take you up on that. You can email me direct at roman (at) romanBANANAblack .com (just remove the FRUIT) to discuss price and mailing if you like. :)
 
ive had a PK3 for a few weeks now, at first i hated it!! but after updating MPLAB and the C18 compiler ive had fewer problems with it. i still find a few quirks now and then but on the whole i am starting to like it. But unless i am using a new chip i tend to use the junebug especialy if i am just doing simple stuff as i like the dev board part of the junebug it makes trying small code snipets out easy as i dont have to mess about building anything on a BB or pcb.
As for language i am still trying to get to grips with C18 but i am likely to switch over to HiTech C, mainly because i want to stick with C but i am using a f16 chip at present and at least Hi Tech C does more than one familly of chips so kind of makes sense to switch over, also it dosnt seem all that different to C18. as for programing language in general, Logan and I have just started to try and learn C#. Ive only realy done a few simple things with Console projects (like the old dos screens) and i find it easier than C for micros so far!! infact i realy like c#. Logan has done some simple windows stuff in C# but its very early days, ive tried VB before but gave up quickly as i just didnt like it, C# seems much better
 
I think everyone should learn to program in Assembly first....I had a great instructor say once "An English speaking American can travel to France and get around OK in English, but to really understand the culture and what the people are thinking, you need to speak French" and I agree. To know what the chip is doing on the base level is something I wouldn't trade for anything. Once you get in to Assembly, you will find you get pretty fast and good at it and I can do some really complex programming faster than you migh think. You do need a higher level language in your back pocket for those super complicated jobs though. Just my $.02 worth. I especially love Assembly for making timers.....every clock cycle is predictable, whereas a C compiled timer requires some sort of calibration. Not the end of the world, but a nice feature with Assy....
 
French people can't speak english and C is not a high level programming language. If you need to "calibrate your C timers" then you are not a very good programmer.
 
Last edited:
and C is not a high level programming language.

Higher than assembler... I get his point... The amount of cycles per instruction can be a bit of an issue.. Usually, even the inbuilt timing functions are not that accurate.
 
If you are primary an assembly language programmer any language other then assembler is high level. For people fluent in several modern high level language there are shades of grey. Both viewpoints have merit.

Asking the world for an answer in not always the best methodology.
 
If you are primary an assembly language programmer any language other then assembler is high level. For people fluent in several modern high level language there are shades of grey. Both viewpoints have merit.

Asking the world for an answer in not always the best methodology.

Totally agree. Python (with NumPy and SciPy) is becoming very commonplace where I am, users of such languages look at C as being a low level language.
 
Last edited:
I don't know why C is considered to be a low level language by anyone. BASIC is universally considered to be a HLL, yet I can write the same program in C using almost identical structure. There's an example following showing the function for calculation of a discrete Fourier transform. So can anyone say that one is high-level and the other is not?

Having the capability to use pointers doesn't make a language 'low level' any more than being able to swing a club makes me a Neanderthal. That said, there are actually pointers available in BASIC using the DEF SEG, VARSEG, VARPTR functions.

The code for DFT in QuickBASIC
Code:
' create an N-point DFT X(k) from x(n). Returns magnitude spectrum
Sub DFT(sn() As Integer, retSk() As Long, N As Long)
    Dim e() As Complex    ' complex exponentials 
    Dim Sk As Complex     ' our temporary complex DFT 
    Dim two_pi_on_N As Single
    
    two_pi_on_N = 2.0*(ATan(1)*4)/N    ' calculate 2pi/N 
    Dim i As Long, j As Long, k As Long

    ' do some precalculations of complex exponential term 
    ReDim e(0 To N - 1)
    For i = 0 To N - 1     ' where i = (kn % N) in the DFT formula 
        e(i).re = Cos(-i * two_pi_on_N)
        e(i).im = Sin(-i * two_pi_on_N)
    Next i

    For k = 0 To N - 1
        Sk.re = 0
        Sk.im = 0

        For n = 0 To N - 1        ' calculate the complex DFT 
            Sk.re = Sk.re + sn(n) * e((k*n) % N).re
            Sk.im = Sk.im + sn(n) * e((k*n) % N).im
        Next n

        ' convert To magnitude, and store in user's buffer 
        retSk(i) = Sqrt(Sk.re*Sk.re + Sk.im*Sk.im)
    Next k
End Sub

The same code in C
Code:
/* create an N-point DFT X(k) from x(n). Returns magnitude spectrum */
void DFT(short sn[], int retSk[], int N)
{
    complex e[N];	/* complex exponentials */
    complex Sk; /* our temporary complex DFT */
    float two_pi_on_N = 2.0*(atan(1)*4)/N;	/* calculate 2pi/N */
    int i, j, k;

    /* do some precalculations of complex exponential term */
    for(i = 0; i < N; i++) 	/* where i = (kn % N) in the DFT formula */
    {
        e[i].re = cos(-i * two_pi_on_N);
        e[i].im = sin(-i * two_pi_on_N);
    }

    for(k = 0; k < N; k++)
    {
        Sk.re = 0;
        Sk.im = 0;

        for(n = 0; n < N; n++)     /* calculate the complex DFT */
        {
            Sk.re += sn[n] * e[(k*n) % N].re;
            Sk.im += sn[n] * e[(k*n) % N].im;
        }

        /* convert to magnitude, and store in user's buffer */
        retSk[i] = sqrt(Sk.re*Sk.re + Sk.im*Sk.im);
    }
}
 
Mr. T....Either folks in Finland must be pretty rude or you're the exception. Also, a lot of French people know English and I am sure they would be insulted if they heard you say that. Just like Finnish don't speak English, right? If you don't know about clock cycles and how in highER languages than assembly you can't be sure how many cycles are executed when you write a batch of code, you are the ignorant one. I can't hate the Finnish because I made a lot of money on the Finnish comany Wartsala last year when they bought my website flexicycle dot c o m for their multifuel oceanliner engines. But I didn't have to deal with ignorance...those were the smart ones of the village, obviously.
 
Mr. T....Either folks in Finland must be pretty rude or you're the exception. Also, a lot of French people know English and I am sure they would be insulted if they heard you say that. Just like Finnish don't speak English, right? If you don't know about clock cycles and how in highER languages than assembly you can't be sure how many cycles are executed when you write a batch of code, you are the ignorant one. I can't hate the Finnish because I made a lot of money on the Finnish comany Wartsala last year when they bought my website flexicycle dot c o m for their multifuel oceanliner engines. But I didn't have to deal with ignorance...those were the smart ones of the village, obviously.

:confused:
 
I don't know why C is considered to be a low level language by anyone. BASIC is universally considered to be a HLL, yet I can write the same program in C using almost identical structure. There's an example following showing the function for calculation of a discrete Fourier transform. So can anyone say that one is high-level and the other is not?

Having the capability to use pointers doesn't make a language 'low level' any more than being able to swing a club makes me a Neanderthal. That said, there are actually pointers available in BASIC using the DEF SEG, VARSEG, VARPTR functions.

The code for DFT in QuickBASIC
Code:
' create an N-point DFT X(k) from x(n). Returns magnitude spectrum
Sub DFT(sn() As Integer, retSk() As Long, N As Long)
    Dim e() As Complex    ' complex exponentials 
    Dim Sk As Complex     ' our temporary complex DFT 
    Dim two_pi_on_N As Single
    
    two_pi_on_N = 2.0*(ATan(1)*4)/N    ' calculate 2pi/N 
    Dim i As Long, j As Long, k As Long

    ' do some precalculations of complex exponential term 
    ReDim e(0 To N - 1)
    For i = 0 To N - 1     ' where i = (kn % N) in the DFT formula 
        e(i).re = Cos(-i * two_pi_on_N)
        e(i).im = Sin(-i * two_pi_on_N)
    Next i

    For k = 0 To N - 1
        Sk.re = 0
        Sk.im = 0

        For n = 0 To N - 1        ' calculate the complex DFT 
            Sk.re = Sk.re + sn(n) * e((k*n) % N).re
            Sk.im = Sk.im + sn(n) * e((k*n) % N).im
        Next n

        ' convert To magnitude, and store in user's buffer 
        retSk(i) = Sqrt(Sk.re*Sk.re + Sk.im*Sk.im)
    Next k
End Sub

The same code in C
Code:
/* create an N-point DFT X(k) from x(n). Returns magnitude spectrum */
void DFT(short sn[], int retSk[], int N)
{
    complex e[N];	/* complex exponentials */
    complex Sk; /* our temporary complex DFT */
    float two_pi_on_N = 2.0*(atan(1)*4)/N;	/* calculate 2pi/N */
    int i, j, k;

    /* do some precalculations of complex exponential term */
    for(i = 0; i < N; i++) 	/* where i = (kn % N) in the DFT formula */
    {
        e[i].re = cos(-i * two_pi_on_N);
        e[i].im = sin(-i * two_pi_on_N);
    }

    for(k = 0; k < N; k++)
    {
        Sk.re = 0;
        Sk.im = 0;

        for(n = 0; n < N; n++)     /* calculate the complex DFT */
        {
            Sk.re += sn[n] * e[(k*n) % N].re;
            Sk.im += sn[n] * e[(k*n) % N].im;
        }

        /* convert to magnitude, and store in user's buffer */
        retSk[i] = sqrt(Sk.re*Sk.re + Sk.im*Sk.im);
    }
}

People that class C as a low level language are used to Matlab and Python (with numPy and SciPy), such people would not even contemplate writing an DFT/FFT as its comes in a default library. Matlab and Python with ... also have methods to remove most for loops.

I love the C language - I have my own mathematics library I have built up over the years :).
 
Last edited:
This is why people say C is a low level language, it has bitwise level code primitives that mimic an assembly language.
https://en.wikipedia.org/wiki/Bitwise_operations_in_C

Other languages have them (usually as an after thought) but C was designed from the start to interact with hardware so it's very efficient at converting the written code into 1 to 1 machine operations.
Code fragments examples for the function blink_led:

Code:
typedef struct V_data { // ISR used, mainly for non-atomic mod problems
    volatile uint32_t buttonint_count, timerint_count, eeprom_count, highint_count, lowint_count, c1_int, c2_int, hunt_count;
    volatile uint32_t pwm4int_count, worker_count, b0, b1, b2, b3, display_count, lcdhits, lcdhits_18tcy, adc_count;
    volatile uint32_t clock20, commint_count, status_count, c1rx_int;
    volatile uint8_t blink, buzzertime, voice1time, voice2time, qei_counts;
} V_data;

struct V_data V;
#define LEDS            LATC

void blink_led(uint8_t led, uint8_t start) // blink and store status of 4 leds
{
    if (led > 3) return;

    if (start) {
        V.blink |= ((LEDS >> led)&0b00000001) << (led + 4); // read the state of the LED on the LATCH and store it on [4..7] of blink
        V.blink |= 0b00000001 << led; // set the blink bit for the LED
    } else {
        V.blink &= ~(0b00000001 << led); // reset the blink bit for the LED
        LEDS &= ~(0b00000001 << led); // reset the LEDS bit for the LED
        LEDS |= (((V.blink >> (led + 4))&0b00000001) << led); // set the LEDS bit
    }
}
 
People that class C as a low level language are used to Matlab and Python (with numPy and SciPy), such people would not even contemplate writing an DFT/FFT as its comes in a default library. Matlab and Python with ... also have methods to remove most for loops.
C/C++/C#/Matlab - they're much the same to me, though C is the least productive, and C# the most. C#, to me, has the most advanced environment to work in out of those mentioned. Matlab is great for uni for any problem that can be vectorised, but is horribly slow for code utilising nested loops; that's when embedding C++ libraries is handy, though I'd prefer they just improved Matlab to be able to handle such cases.
 
Extensive library does not make a language high level. Try some C without libraries and you'll see that it is not a high level language. Try some Assembly with extensive libraries (macros, procedures and data structures) and you'll see that it is not very far from C.

If you would list programming languages from low-level to high-level, C would come right after Assembly. I can't think one single programming language that is more low-level than C, but higher than Assembly. So, how can somebody call C a high level language?

C was a high level language maybe 30 years ago, but not anymore. It is practically the only language that survived from the third generation languages.
 
Last edited:
If you would list programming languages from low-level to high-level, C would come right after Assembly. I can't think one single programming language that is more low-level than C, but higher than Assembly. So, how can somebody call C a high level language?

Because it's not assembler - anything other than that is an HLL.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top