News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

ChatGTP

Started by ken_k, Dec 16, 2022, 02:36 AM

Previous topic - Next topic

ken_k

The internet is abuzz with discussions about ChatGPT AI.

Is this the future of coding?
Will this help with homework?
Can it write Proton Basic?
Will it save me time?
Is it a threat to Google?
Is it smarter then me? y


https://www.youtube.com/watch?v=40Kp_fa8vIw

https://www.youtube.com/results?search_query=chat+gpt+writes+code

https://www.youtube.com/watch?v=JxSlGQrXsdo

I know this is not really relevant to this forum? But it might be!

Ken K

ken_k

#1
Ok I tried this.

Q/  Can you write in proton basic language?

A/  Yes, I can write in Proton Basic. Proton Basic is a programming language that is designed for use with the Proton Development Suite, a set of tools for developing microcontroller-based projects. Proton Basic is based on the BASIC programming language and is similar to other BASIC dialects, such as Microsoft Visual Basic and Liberty BASIC.

Here is a simple example of a Proton Basic program that blinks an LED connected to pin 1 on a microcontroller:

Copy code
' Blink an LED on pin 1

DO
    HIGH 1 ' Turn on the LED
    PAUSE 500 ' Wait for 500 milliseconds
    LOW 1 ' Turn off the LED
    PAUSE 500 ' Wait for 500 milliseconds
LOOP
This program consists of a loop that alternates between turning on and off the LED connected to pin 1 on the microcontroller. The PAUSE statement is used to pause the program for a specified number of milliseconds.

To run this program, you will need the Proton Development Suite, which includes a Proton Basic compiler and other tools for developing microcontroller-based projects. You can find more information about the Proton Development Suite at the following website:

https://www.siriusmicrosystems.com/

I hope this helps! If you have any questions about Proton Basic or if you need further assistance, don't hesitate to ask.kwk@internode.on.net


Q/ can you code in positron16 basic?
A/ I apologize for misunderstanding your previous question. It appears that you are asking about a programming language called Positron16 Basic.

I am not familiar with a programming language by this name. It is possible that you may be thinking of another programming language or tool. It is also possible that Positron16 Basic is a fictional programming language or a variant of another programming language, such as Positron Basic or some other version of BASIC. Without more information, it is difficult for me to provide a more specific response. If you have any additional information or context that might help me to better understand your question, please let me know and I will do my best to assist you.










RGV250

Hi Ken,
I find it amazing what people seem to think is fantastic on the internet, obviously pople who cannot figure it out for themselves.
All it appears to have done is copied and pasted an example from Les's website, hardly writing code.
If the future programmers are relying on this heaven help us.

Bob

keytapper

I think the answer will be NO. Here is for Positron basic  ;D
Is the proton compiler deprecated? Might be.
Ignorance comes with a cost

dnaci

Openai chatGPT artificial intelligence only knows the information available until 2021. So he doesn't know about the positron compiler. There fore positron does not know. But he learned proton basic. :D

xldaedalus

I have been playing around with ChatGPT.  People said the same kind of thing about Google when it first appeared. ChatGPT as "AI" appears to be something like an automated Google.  It knows human knowledge, it know how to write code, if told how to write the code and make it better. But it is very unlikely it will create "original" code.  I see it for what it is intended to be, a tool to learn and increase productivity.  It seems about as good as an super smart 8 year old.  It knows stuff, like using a pencil can "write" stuff, without understanding how the pencil works and how that understand can be applied to making a ball point pen.

And the most important fact is that ChatGPT learns.  So, if we all start using it, we can teach it how to be a better code creator.

Here is an example dialog I had with it.

Can you write a Proton Basic Program that will convert 0-255 into fStops f1.2 to f22?

Yes, here's an example Proton Basic program that converts values ranging from 0 to 255 into f-stops ranging from f/1.2 to f/22:

vbnet
Copy code
; Proton Basic program to convert values from 0 to 255 into f-stops from f/1.2 to f/22

; Define variables
Dim value As Byte
Dim fStop As Float

; Main program loop
Do
    ; Read input value from analog input
    value = ADCIN 0

    ; Convert input value to f-stop value
    fStop = (22.0 - 1.2) * (value / 255.0) + 1.2

    ; Display f-stop value on LCD or other output
    Print "f/", Format(fStop, "0.1")

    ; Delay for a short period of time
    DelayMS 100
Loop
In this program, the input value is read from an analog input using the ADCIN command, which returns a value ranging from 0 to 255. This value is then converted to an f-stop value using a linear scaling equation that maps the input range of 0-255 to the output range of f/1.2 to f/22. The resulting f-stop value is then displayed on an LCD or other output device using the Print command. The program loops continuously, reading the input value, converting it to an f-stop value, and displaying the result with a short delay between iterations.




leefparker@yahoo.com
Can you convert that to a Procedure?

Sure, here's an example of how you could convert the previous program into a procedure:

vbnet
Copy code
; Proton Basic procedure to convert values from 0 to 255 into f-stops from f/1.2 to f/22

; Define procedure to convert value to f-stop
; Takes a byte value as input and returns a float f-stop value
; Input value should be in the range of 0-255
Procedure ConvertTofStop(value As Byte) As Float
    Dim fStop As Float
    fStop = (22.0 - 1.2) * (value / 255.0) + 1.2
    Return fStop
EndProc

; Main program loop 'Use in an example program
Do
    ; Read input value from analog input
    Dim value As Byte
    value = ADCIN 0

    ; Convert input value to f-stop value
    Dim fStop As Float
    fStop = ConvertTofStop(value)

    ; Display f-stop value on LCD or other output
    Print "f/", Format(fStop, "0.1")

    ; Delay for a short period of time
    DelayMS 100
Loop

In this program, the conversion of the input value to an f-stop value has been moved into a separate procedure called ConvertTofStop. The procedure takes a byte value as input and returns a float f-stop value. The main program loop reads the input value, calls the ConvertTofStop procedure to convert the value to an f-stop, and then displays the result with a short delay between iterations. The advantage of using a procedure is that it can be reused in other parts of the program or in other programs.

You will note there are mistakes, but the basic form is correct.  I don't know if we can teach it, but I am going to try.


leefparker@yahoo.com
Can you convert this into Microchip 18F assembly code?
Certainly, here's an example of how you could convert the previous Proton Basic program into Microchip 18F assembly code:

vbnet
Copy code
; Microchip 18F assembly program to convert values from 0 to 255 into f-stops from f/1.2 to f/22

; Define constants
equ ADC_CHANNEL = 0x00       ; Analog channel 0
equ LCD_DATA = 0xFE          ; LCD data command
equ LCD_CLEAR = 0x01         ; LCD clear command
equ LCD_HOME = 0x02          ; LCD home command

; Main program
Main:
    ; Initialize ADC
    movlw b'00000001'         ; Set ADC clock to Fosc/8
    movwf ADCON2
    movlw b'00000000'         ; Set ADC reference to Vdd
    movwf ADCON1
    bsf ADCON0, 0             ; Turn on ADC

    ; Initialize LCD
    movlw LCD_DATA            ; Select data command
    call SendLCD
    movlw LCD_CLEAR           ; Clear LCD display
    call SendLCD
    movlw LCD_HOME            ; Move cursor to home position
    call SendLCD

    ; Main program loop
Loop:
    ; Read input value from analog input
    clrf ADRESH                ; Clear ADC result registers
    clrf ADRESL
    bsf ADCON0, 1             ; Start ADC conversion
    btfsc ADCON0, 1           ; Wait for conversion to complete
    goto $-1
    movf ADRESH, w            ; Read ADC result into W register
    movwf value               ; Move value into variable

    ; Convert input value to f-stop value
    movf value, w             ; Move value into W register
    movwf temp                ; Move value into temporary variable
    movlw d'255'              ; Load constant into W register
    subwf value, w            ; Subtract value from constant
    movf temp, w              ; Move temporary variable into W register
    mulwf fStopScale          ; Multiply by f-stop scale factor
    movlw d'120'              ; Load constant into W register
    addwf prod, f             ; Add to product
    movlw d'1'                ; Load constant into W register
    movwf prod+1              ; Move constant into upper byte of product
    movf prod+1, w            ; Move upper byte of product into W register
    movwf fStop               ; Move f-stop value into variable

    ; Display f-stop value on LCD
    movlw LCD_DATA            ; Select data command
    call SendLCD
    movlw 'f'                 ; Display "f/"
    call SendLCD
    movf fStop, w             ; Move f-stop value into W register
    call DisplayFloat         ; Display f-stop value
    call Delay                ; Delay for a short period of time
    goto Loop

; Subroutine to send data to LCD
SendLCD:
    movwf PORTB                ; Send data to LCD
    bsf PORTC, 0              ; Set RS bit
    bsf PORTC, 1              ; Set E bit
    call Delay                ; Delay for a short period of time
    bcf PORTC, 1              ; Clear E bit
    return

; Subroutine to display a floating point number on LCD
DisplayFloat:
    movlw d'10'               ; Load constant into W register
    movwf digits              ; Move constant into digits counter
    movlw d'0'                ; Load constant into W register
   
Never, never, never give up

Gary Scott

#6
Give it a few years and AI will be a very useful tool, at least for us dummies that can't do it for ourselves and use such tool such as search engines

John Drew

xldaedalus,
It did a better job than I anticipated. I wonder if it would have included fuses if you told it the PIC type?
John

TimB


Ref fuses. Yesterday I asked Chatgpt to workout the fuses for a pic to run at 32Mhz on the internal osc

First attempt made a very coherent attempt but was wrong. I tried again correcting myself to ask for the OSCONN settings I actually learn something from its answer but again it was wrong.

As an example of what chatgpt can do writing code I recommend the eevblog video from a couple of days back where Dave gets it to write some Arduino code to drive 7 seg led displays

https://youtu.be/g5_Ts9SWbYs


kcsl

I've played quite a bit with it and it's a clever piece of technology no doubt, but I think the concept has a basic flaw.
If you enter a search into Google & adverts aside, you get a gazillion results and usually you can see a common theme just from the summary lines from each result displayed to get an idea of what answer you should be expecting. If 99% of the results are saying yes, it's probably fair to say the correct answer is yes. Not always, but it's a good place to start.
Chatgpt gives often gives you a lovely expanded answer that can just be completely wrong... and it lies so convincingly.

I am currently debugging a fault on an Acorn BBC computer, a computer I used extensively as a kid back in the 80's and so know fairly well.
I asked this question:
"any idea why an acorn bbc computer only displays lower case characters in mode 7"

This is it's reply:
"The Acorn BBC Microcomputer in Mode 7 displays a 40-column text display with 256 characters, but it is typically limited to only displaying lowercase characters. This is because Mode 7 uses a graphics mode that utilizes a 6x8 pixel font, which only contains lowercase characters.

If you want to display uppercase characters in Mode 7, you can modify the character set to include them. One way to do this is to create a custom character set with uppercase letters and load it into memory. There are also programs available that can modify the existing character set to include uppercase letters.

It's worth noting that the original design of the BBC Microcomputer was geared towards the education market, and lowercase letters were considered sufficient for most text-based programming tasks. The addition of uppercase letters in Mode 7 was not considered a high priority, as the other text modes (e.g., Mode 0, Mode 1) could display both uppercase and lowercase characters."


It's completely and totally wrong. I suspect it's actually talking about the Acorn Atom computer, but it's do darn convincing that it had me checking to manual to see if my memory was failing, and it's this that I don't like. It gives you one apparently well thought out and informed answer, and it can be a complete load of rubbish.

FYI... the fault with my BBC is a RAM failure.

Regards,
Joe

There's no room for optimism in software or hardware engineering.

RGV250

Hi,
I am no expert in assembler but the example for Xldaedalus has schoolboy errors and would crash the first time it was run (if it actually could run). The bit I find worrying as well is that he said he teaches it, this is not meant as a criticism to his ability but to all the garbage out on the internet that if anyone can teach it then how will it know when someone tells it a load of garbage. it is a bit like if les or me gave an answer about the compiler who would you trust. Unfortunately this so called intelligence will trust anyone who decides to try to teach it and is probably not intelligent enought to tell.

Thwere is another worry here, when everyone is too stupid to work things out for themselves there will not be anyone to tell it if it is wrong, when it does write software I hope it is not for aircraft and if so they tell us so I can stay in the airport bar so avoiding the subsequent crash.

Bob

xldaedalus

#11
Quote from: RGV250 on Feb 26, 2023, 09:11 AMI am no expert in assembler but the example for Xldaedalus has schoolboy errors and would crash the first time it was run (if it actually could run).

Like I think I said, the AI seems to be a very intelligent 8 year old.  I didn't say the conversion from basic to ASM was correct or wouldn't crash.  I merely pointed out it could be done.  AI at the moment is like an Idiot Savant. An Idiot Savant can tell me April 1st 1857 was a Tuesday but he can't tie his shoes. An Idiot Savant can tell me Pi to a million places but he can't explain what Pi is. An Idiot Savant can hear Chopin once, and play the Chopin like Chopin, but he can't create like Chopin.  ChatGPT isn't going to replace people like you and Les any time soon. And that isn't my point, or even relevant IMHO.

For a person who's never programmed, creating a weather station to run, or a show with his Christmas lights might not seem so daunting with ChatGPT to help him. Millions of people have seized upon crappy code writing by jumping on the Arduino platform.  But people with the passion for coding learn how to make their code better.  Herman Melville started with a DICK AND JANE primer before he wrote MOBY DICK, same is true for all of us here.

ChatGPT will encourage people to buy Les's Compiler, because, if you don't know anything, you won't know the program doesn't work until you try it.  You can't try it unless you have a Positron(Proton) compiler.  And you won't try it if you think it will generate crap code.  Once this person finds out it doesn't work, he has to figure out WHY it doesn't work, and this is where the learning starts.  If the person doesn't have the patience to figure out how to fix the code, then he doesn't deserve to be able to create his OWN Weather Station or Christmas Light Show.  Any if code generation by ChatGPT teaches you anything, it teaches you proper formatting and commenting.

Approaching the idea that the method obtain any kind of "true" knowledge as "you walk the Trail of Tears to obtain it" is arrogant, and BS.  Its just as arrogant as a C programmer saying his code better than a Positron Basic Code.  That AI isn't perfect, AI can't be trusted to be right are valid (and obvious) points. But dismissing the potential of AI is foolhardy just because it can't, as of this writing, write proper ASM, or makes mistakes writing Basic. AI in all its forms, sad and dangerous as these may be, is here to stay.

Personally, I think we should encourage people to have AI help them write their BASIC programs because it will help Les sell compilers, which, in turn, will help Les continue to improve and expand Positron into 32b machines, like ARM.  This will help all of us make better devices.  And isn't that more important, especially for this forum? 

After all, have you considered the reason ChatGPT is better at writing Java and C++ code is because it has millions of examples to learn from?  I think its doing pretty damn well given the paucity of examples of "Proton Basic" it must have to base its "guesses" on.  It won't get better unless it has more examples of correct code to learn from and improve.  In this respect, it's no different than we are.

I think ChatGPT could help us create an open source code library as powerful as Arduino's and easier to learn and use.  This would be good for all of us, but especially for Les, without whom we wouldn't be here.
Never, never, never give up

Gary Scott

#12
Quote from: RGV250 on Feb 26, 2023, 09:11 AMThwere is another worry here, when everyone is too stupid to work things out for themselves there will not be anyone to tell it if it is wrong, when it does write software I hope it is not for aircraft and if so they tell us so I can stay in the airport bar so avoiding the subsequent crash.
Bob

 With that logic, should it also not apply to high level languages like Python, Basic etc etc? Do we need to write in assembler to be "smart"?
 I'm by no means saying AI is ready for prime time, but it WILL be the future. Period.
I'm shocked to say the least that so many tech minded folks are so closed minded about innovation and the future.
My health is way less than perfect, so to be very honest I'm jumping for joy  to see a hint of what the future holds for humans

RGV250

I object to the "intelligence", if this is the case then why do we not call calculators maths teachers. In my opinion it is nothing more than a glorified search engine.

QuoteAI in all its forms, sad and dangerous as these may be, is here to stay.
The reason it is here to stay is people are too lazy to think for themselves, look how kids are using it to do their schoolwork.

Bob