News:

Let's find out together what makes a PIC Tick!

Main Menu

Teaching ChatGPT the Positron language

Started by top204, Sep 04, 2024, 04:29 PM

Previous topic - Next topic

top204

As the title states, I have been spending a few hours teaching chatGPT the Positron syntax and have asked it to perform some coding tasks.

Not very successfully, I may add, because it keeps forgetting what I told it after a few code productions of different things, and the code it produces looks OK, but does not work at all the way it should, even when I ask it to produce C code! And it will never admit that it got the code wrong and creates more code that does not work as it should. Even when I asked it to produce an image of a 3D maze program it produced on an LCD, it made up an imaginary image and did not actually simulate the code, then appologised when I confronted it, and then did the same thing again with another imagined image that had nothing to do with 3D, but a perpective view that the code could not possibly produce!

Then my time ran out and I have to wait another 24 hours, because "guess what?" You have to pay to use it... Who would have thought that? :-)

I've tried other, so called, AI sites and they are quite dreadful, and a whole lot worse than chatGPT.

I know it has only newly been created, but chatGPT is still quite remarkable and very scary, because in a few years, it will be able to produce code that works perfectly on any device and for any purpose, and at remarkable speed. i.e. A few minutes! And the images it produces (two maximun when free) are incredible.

So, in a few years time... No artists required, no designers required, no writers required, no engineers required, in fact no specialised humans required at all. Some will not be missed and should be gotten rid of as soon as possible. i.e. Estate agents, lawyers, dodgy accountants, managers with no skills at all, civil servants, and bureaucrats etc, but for the skilled people who do honest work for a living, their profession will be a thing of the past.

Just like when the industrial revolution first happened in the 1700s, and 10s of thousands of skilled workers were not needed anymore, and made to work in factories for pennies to make the rich richer, and the, once, skilled workers poorer. It looks like history is repeating itself, yet again! But it will not be 10s of thousands of workers only here in the UK this time, it will be millions of skilled workers, if not billions of skilled workers around the planet, because of the amount of humans on the planet now... Very scary indeed, and unfortunately, a coming reality. :-O 

trastikata

Hello Les,

I've also found out that ChatGPT goes into circles when you present reasons why the code being generated is wrong and the algorithm can't actually be "taught" behind what information has been scraped from I-net...


ken_k

Quote from: top204 on Sep 04, 2024, 04:29 PMEstate agents, lawyers, dodgy accountants, managers with no skills at all, civil servants, and bureaucrats etc, but for the skilled people who do honest work for a living, their profession will be a thing of the past.
 

This reminded me of Arc Ship B in the book Hitchhiker's Guide to the Galaxy by Douglas Adams.


kcsl

I was about to say, one of the problems with ChatGPT is that it doesn't remember things you tell or teach it, and to a degree this makes sense. Can you imagine if the flat earthers got to influence what it knew. But it's still a very useful tool and I use it for all sorts of things, but today it asked me "do I want to enable it's memory feature".

https://www.techopedia.com/is-chatgpt-memory-worth-turning-on-exploring-openais-little-known-feature#:~:text=ChatGPT%20memory%20doesn%27t%20have,to%20help%20train%20OpenAI%27s%20models.

It appears that it can now remember things from your conversations; and you have controls over what it remembers or forgets which is useful.
So now, in theory, you can teach it about a new programming language, but this new knowledge will for now anyway, be private to you and your conversations.

However, I'm not worried about the future with AI.
Right now, it's not capable of original thought. It can only remix existing information.
And anybody who's used AI for a while, will know just how well it can hallucinate, and it does it so convincingly.

SQL was supposed to be the end to the database programmer, Excel was going to eliminate the need for accountants.

If you needed any proof as to just how stupid it is, I just played a game of connect4, and apparently beat it. Which is news to me as I was plotting the game on a piece of paper and when it suddenly announced I'd won, I asked it to show me the game board. The picture is what it came up with. Very pretty and all but a complete piece of fiction. And I certainly didn't win... I never had more that two consecutive pieces.
I'm not worried.
There's no room for optimism in software or hardware engineering.

RGV250

QuoteIf you needed any proof as to just how stupid it is, I just played a game of connect4, and apparently beat it. Which is news to me as I was plotting the game on a piece of paper and when it suddenly announced I'd won, I asked it to show me the game board. The picture is what it came up with. Very pretty and all but a complete piece of fiction. And I certainly didn't win... I never had more that two consecutive pieces.
I'm not worried.
Perhaps it got mixed up with chess and thought there were some "Knight" pieces.

It could have picked blue which was the original colour for the frame.

Bob

top204

#5
I had forgotten about that Ken.

Douglas Adams was a clever writer, and he, as most 'normal' people do, see them as a bit of a waste of skin, and the world would actually be a bit of a better place without most of them. LOL

In the book and the TV series, the Arc Ship B was the spaceship where the captain stayed in the bath tub 24 hours a day drinking cocktails, and did sod all of any practical use, and it was the people around him that did all the work, but most of them had their heads up their own arses as well (Wow... Just like some civil servants I have known in my life). And the spaceship was full of the beings that were not needed or wanted in society and they wanted rid of them, so they sent them off into space in a state of suspended animation. Just like most of the above mentioned people should be. :-)

The late 1970s BBC TV series of "The Hitchhikers Guide To The Galaxy" is highly recommended to watch. It is brilliantly written and acted, and converted from Douglas's book excellently. Unlike that dreadful film they made of it in the early 2000s, which was utterly dreadful hollywood crap!

The 1970s BBC Radio series of "The Hitchhikers Guide To The Galaxy" is also excellent to listen to.

For readers who do not quite understand the meaning of "heads up their own arses". It means they are full of "self importance", and are "never wrong".

Stephen Moss

Quote from: top204 on Sep 04, 2024, 04:29 PMAs the title states, I have been spending a few hours teaching chatGPT the Positron syntax and have asked it to perform some coding tasks.

Not very successfully, I may add, because it keeps forgetting what I told it after a few code productions of different things, and the code it produces looks OK, but does not work at all the way it should, even when I ask it to produce C code!
I don't get involved with it as you have to pay and I would not use it enough to justify the cost, but I don't think it really learns as such (at least not yet), like most people who cannot be bother to learn how to code I think that currently it just scours the internet for posts that mention key words, assumes the associated posted code code will do what you want and then uses copy & paste to lash various bits together and hope the result works.

Quote from: top204 on Sep 04, 2024, 04:29 PMEven when I asked it to produce an image of a 3D maze program it produced on an LCD, it made up an imaginary image and did not actually simulate the code,
I think that depends on the text of your query, it probably understood "produce an image of a 3D maze", ignored the rest and mocked one up. I am not sure how it could simulate the code without having a simulator of its own built in to it as if that is not the case I would think it would need to access a paid subscription to the relevant software.

Quote from: top204 on Sep 04, 2024, 04:29 PMI know it has only newly been created, but chatGPT is still quite remarkable and very scary, because in a few years, it will be able to produce code that works perfectly on any device and for any purpose, and at remarkable speed. i.e. A few minutes! And the images it produces (two maximun when free) are incredible.

So, in a few years time... No artists required, no designers required, no writers required, no engineers required, in fact no specialised humans required at all.
As it stand like a lot on new things I think it is over-hyped, and only time will tell whether it proves to be the dawn of a new age as it is being touted or the beginning of the downfall of mankind.

Because if but if it self learning (beware SkyNet) and live up to the hype then the problem is that it could eventually result in skilled people being replaced by unskilled ones a lower wage just asking it to produce whatever for them, or nobody.
Which could then mean more people vying for fewer (and lower paid) jobs leading to more poverty, which in turn could result in the civil unrest and break down of society that is to an extent we are already get the occasional glimpses of in some of the poorer nations become a global issue.

Fortunately, whichever way it goes I don't think it will occur quickly enough to have a major effect on my life.   

JonW

#7
I have been using Free Claude AI, and I can say it's pretty spectacular for explaining and sifting through specifications, generating basic examples of code or explaining pre-written code flow.  I am also learning C to help with the USB coding on embedded and PC processors and can say that the AI is proficient at writing, and in most cases, it gets really close and really quick! 
I also gave it the task of calculating some really complex RF mixer matrices, and it did them with ease in the blink of an eye.  It knew about higher-order mixing products, image frequencies, high and low side injection, etc.  I think if you use it as an assistant to crunch data, then it's pretty efficient. 

Take a look at this use case of Claude, writing a protocol analyser for the Salae logic 8.  Claude AI Protocol Building and also Claude AI Protocol Building 2

top204

#8
Thanks Jon.

I'll try out Claude AI.

I have tried quite a few other free, so called, AI sites, and they are really dreadful.

That decoding of the I2C data for the LCD looks incredible!

JonW

#9
Take a look at it. You get quite a number of free entries. I think the examples I posted are the paid version, just because of the amount of data he uploaded.  Even so this is quite staggering to build a framework for you to work on. 

As an example, I uploaded the base 16F1459 outline .bas and asked it to write a ring buffer and a linear buffer, interrupt driven with a termination character for Positron. 

Within 2 goes it got it.  I really like the way it used modulo for the ring buffer checking, very neat.


 (*************************************************************************************************
* Name      :  BASE1459.bas
* Author    :  Claude AI (with a bit of help)
* Copyright : 
* Version   :  0.1.0.0
* History   :  03 AUG 2024
* Notes     :  STARTING BASE SETUP + Ring Buffer
***************************************************************************************************)

'------------------------------------------------------------------------------------------------
'                                        COMPILER SETUP
'------------------------------------------------------------------------------------------------
    device = 16F1459
    xtal = 48                     ' CLKOUT WILL BE CLK/4
    On_Hardware_Interrupt GoTo ISR_Handler              ' Point to the interrupt handler routine
    DECLARE HSERIAL_BAUD = 115200
'------------------------------------------------------------------------------------------------
'                                       INCLUDE FILES
'------------------------------------------------------------------------------------------------


'------------------------------------------------------------------------------------------------
'                                       NVM STORES
'------------------------------------------------------------------------------------------------
    Symbol STARTADD = 14000               ' LOCATION IN FLASH


'------------------------------------------------------------------------------------------------
'                                    CONSTANTS AND ALIAS'
'------------------------------------------------------------------------------------------------
    Symbol MCP4XXXSDA       = PORTA.4         ' PASSES THE PINS TO THE SWI2C PROCS
    Symbol EOM = "%"                       ' UART END OF MESSAGE FLAG



'------------------------------------------------------------------------------------------------
'                                    VARIABLE DECLARES
'------------------------------------------------------------------------------------------------
    Dim bTEMP               As Byte         ' TEMP VAR

    Dim SerialIn            As Byte
    Dim SerialBuffer[64]    As Byte
    Dim BufferHead          As Byte
    Dim BufferTail          As Byte
    dim BytesinBuffer       as byte         ; MAYBE NOT NEEDED IF WE KNOW WHERE THE EOM CHAR IS
    dim EomTailNum          AS BYTE         ; IF THE EOF IS RECEIVED THEN THE BUFFERTAIL IS STORED
    dim EomFlag             as bit          ; FLAG TO INDICATE EOM RECEIVED
    DIM RxBufferPop         as bit          ; FLAGS THE BUFFER HAS OVERFLOWED

    DIM INT_TMR             AS WORD         ; TICK UP EVERY 100U


'------------------------------------------------------------------------------------------------
'                                        PORT SETUP
'------------------------------------------------------------------------------------------------
    DIM LED1             AS LATC.0
    DIM SW1              AS PORTC.0




'------------------------------------------------------------------------------------------------
'                                    RESET & DEVICE SETUP
'------------------------------------------------------------------------------------------------
    osccon = %11000000                  ' PLL EN, 3X PLL, 16M INT, CLK BY FOSC2 IN CONFIG
    WHILE OSCSTAT.1 = 0  : WEND        ' WAIT FOR STABLE PLL
    OUTPUT LED1
    ANSELA = 0: ANSELB = 0: ANSELC = 0  ' ALL DIGITAL
    TRISA = %00000000
    TRISB = %00100000
    trisc = %00000000

    BUFFERHEAD = 0
    BUFFERTAIL = 0




' Enable interrupts
    PIE1.5 = 1        ' Enable UART receive interrupt
    INTCON.6 = 1      ' Enable peripheral interrupts
    INTCON.7 = 1       ' Enable global interrupts




'------------------------------------------------------------------------------------------------
'                                          CODE START
'------------------------------------------------------------------------------------------------

MAIN:



    TOGGLE LED1

    WHILE BUFFERTAIL <> BUFFERHEAD
         HRSOUT SERIALBUFFER[BUFFERTAIL]
         BufferTail = (BufferTail + 1) // 64
    WEND
    IF EOMFLAG = 1 then
            hrsout "EOM RXD",13,10
            eomflag = 0
    EndIf
    delayms 500
    GOTO MAIN



'------------------------------------------------------------------------------------------------
' Interrupt handler routine
' Input     : None
' Output    : Array USART1_bRingBuffer holds the characters received from USART1
'           : USART1_bIndexIn points to the current location within the USART1 buffer
'           : Global_tByteInBuffer1 is true if a byte was received on USART1
' Notes     : Interrupts on USART1 receive
'
ISR_Handler:
    Context Save FSR1L, FSR1H                           ' Save any compiler system variables and any SFRs used before we perform the interrupt code


    If RCSTA.1 = 1 Then
        RCSTA.4 = 0: NOP: RCSTA.4 = 1    ' IF OVERRUN THEN RESET CREN AS THIS CAN BLOCK THE UART
    ENDIF
' Check the USART1 RX interrupt
'
    If PIR1.5 = 1 Then  ' Check if it's a UART receive interrupt
        SerialIn = RCREG   ' Read the received byt

        ' Store the received byte in the circular buffer
        SerialBuffer[BufferHead] = SerialIn
        BufferHead = (BufferHead + 1) // 64

        ' Check for buffer overflow
        If BufferHead = BufferTail Then
            BufferTail = (BufferTail + 1) // 64  ' Discard oldest byte
            RXBUFFERPOP = 1                   ; FLAG BUFFER LIMIT HAS BEEN BREACHED
        EndIf

        IF SERIALIN = EOm then
           EOMTAILNUM = BUFFERTAIL            ; STORE THE LOCATION OF THE EOM CHARACTER
           EOMFLAG = 1                        ; FLAG WE HAVE A EOM IN BUFFER
        EndIf

    EndIf

    ' Clear the interrupt flag
    PIR1.5 = 0

    Context Restore


PROC GETBYTES()
        bytesinbuffer = (BufferHead - BufferTail + 64) // 64
        hrsout "BH = ", dec3 bufferhead, " BT = ", dec3 buffertail,13,10
        hrsout " THERE ARE ", DEC2 BYTESINBUFFER, " BYTES IN THE BUFFER",13,10
EndProc





'-------------------------------------------------------------------------------
'**** Added by Fuse Configurator ****
' Use the Fuses Tab to change these settings

Config1 FOSC_HS, WDTE_OFF, PWRTE_OFF, MCLRE_ON, CP_OFF, BOREN_ON, CLKOUTEN_OFF, IESO_ON, FCMEN_ON
Config2 WRT_OFF, CPUDIV_NOCLKDIV, USBLSCLK_48MHz, PLLMULT_3x, PLLEN_ENABLED, STVREN_ON, BORV_LO, LPBOR_OFF, LVP_ON

'**** End of Fuse Configurator Settings ****
'---

JonW

Another great use was that I asked it to tabulate the precedence in C as a commented code block.  It produced this in about half a second.

/*
|TITLE:  USB BUFFER WITH TASK TIMER (INT DRIVEN) INC RS232 + STRING COMPARE
|AUTHOR:
|DEVICE: PIC16F1459
|NOTES:  RUNNING CDC USB STACK V1.0
|
| Precedence | Operator                          | Name                                                                                                    |
|------------|-----------------------------------|---------------------------------------------------------------------------------------------------------|
| 1          | () [] -> .                        | Parentheses, Array subscript, Member access                                                             |
| 2          | ! ~ ++ -- + - * & (type) sizeof   | Logical NOT, Bitwise NOT, Increment/Decrement, Unary plus/minus, Indirection, Address-of, Cast, Size-of |
| 3          | * / %                             | Multiplication, Division, Modulus                                                                       |
| 4          | + -                               | Addition, Subtraction                                                                                   |
| 5          | << >>                             | Bitwise left shift, Bitwise right shift                                                                 |
| 6          | < <= > >=                         | Relational operators                                                                                    |
| 7          | == !=                             | Equality, Inequality                                                                                    |
| 8          | &                                 | Bitwise AND                                                                                             |
| 9          | ^                                 | Bitwise XOR                                                                                             |
| 10         | |                                 | Bitwise OR                                                                                              |
| 11         | &&                                | Logical AND                                                                                             |
| 12         | ||                                | Logical OR                                                                                              |
| 13         | ?:                                | Conditional (Ternary) operator                                                                          |
| 14         | = += -= *= /= %= &= ^= |= <<= >>= | Assignment operators                                                                                    |
| 15         | ,                                 | Comma operator                                                                                          |
|----------------------------------------------------------------------------------------------------------------------------------------------------------|
*/

JonW

Les take a look at the second video clip I posted.  You must admit this is pretty impressive!!

top204

#12
It is impressive Jon.

I tried Claude, and it does look good. However, I gave it the same simple challenge to write a BASIC program to generate a navigatable 24x24 random maze and draw a first person 3D perpective of the maze on a 128x64 graphic LCD where a player is standing within it, using lines in a hidden line algorithm so walls that should not be seen, cannot be seen, and entrances to maze corridors visible.

It created almost identical code to chatGPT, and just like chatGPT, it did not work either. Neither the maze creation or the 3D view was anything like working code! So there is a lot of copy and paste going on underneath them. However, it did change variable names, but not all procedure names, from each other's code they scanned from the internet.

Then I ran out of time and it is asking £18 per month to use the bonus version!!!! £18 per month! What a ridiculous amount of money for something to surf the internet and make random guesses that waste a person's time trying them.

I remember writing a similar program back in the 1980s for my ZX Spectrum computer using its Draw command. And written in, very basic, BASIC of the time!

About 12 years ago, I also created a similar 3D maze using a PIC18F25K20 in Proton BASIC, that displayed a 3D maze view on a 128x64 graphic LCD, using the Amicus18 board and a KS0108 display. It used a simple RayCasting method, so it can be done relatively easily in the BASIC language, but not for super intelligent AI programs that seem to want to rip gullible people off. :-)

The more I look at AI, I take back my comments in the first post. Unless they actually start to "think" for themselves when creating, and actually become AI instead of a "buzz" word, they are simply a giant database and search engine with some, what they used to call, fuzzy logic in it. So it will be a very, very long time before they can replace a human mind for creativity. Copying yes, and very good at hiding it, and a very good giant scientific calculator, but not actually creating!

JonW

That may be a bit of an ask for the current AI! From experience, it's best to break it into much smaller tasks. There was an interesting interview with the ex-CEO of Google, and he said the next level of AI in the coming year will be a totally different beast. Their issue right now is how much power the huge data centres need to run! The point is that if they become that smart, then we are all doomed.  Personally, I like it as it is, with some help from AI crunching numbers, sorting and processing data.  Even at its current level, with all the information at hand, it's an extremely powerful tool.  I know you say £18 a month is a lot, but if it can save hours of work, then it's worth the investment.  Not sure if the paid version opens up the more advanced AI engine.

See_Mos

I just asked Microsoft Copilot to suggest the fastest eight pin PIC.  The suggested device was PIC12F675 which can run at 20MHz so I asked Copilot how it compared to the 12F1840 which can run at 32MHz and it gave comparisons between the two.  I then asked for the fastest 14 pin device and Copilot suggested the 16F1455 at 48MHz.  I don't know if there are any faster 8 pin or 14 pin devices but I must say the answers were a lot quicker than trying to search the Microchip web pages.

top204

#15
That is second guessing by it, and reading, and actually believing, what is on the internet! Which is a very dangerous thing to do, for human or machine, because there is so much nonsense and guesses on it by people who "know everything", when in fact know very little, or people who "are never wrong, so whatever guessed at by quickly viewing and not actually studying will be believed" etc... In my career, I have come across those scenarios many, many times, in computing and electroncs design, and repairing. And quite a few of them were from managers or supervisors of companies I worked for in my lifetime.

The fastest 8-pin PIC 8-bit devices are the enhanced 14-bit core types, because they can operate at 32MHz (or more). But more importantly, they have a bit more refined set of mnemonics and a different architecture to standard 14-bit core devices, and have a mechanism to access RAM and Flash memory linearly when reading/writing indirectly, so even when both types are operating at 20MHz, the enhanced 14-bit core device will be faster for all "real world" programs. They also support more RAM and flash memory than standard 8-bit devices. However, they come a very second place to the 18F devices, and the newer 18F Q devices are 14-pins upwards and operate at 64MHz (or more).

I recently used a 14-pin PIC18F05Q41 device in an application and it works lovely and fast, and reliably at 64MHz, and I know, by tests, they will happily work up to 100MHz using a 25MHz crystal or resonator and the 4xPLL enabled, but how reliable they are at those speeds I have not tested fully. i.e. Hot and cold temperatures.

JonW

Speed is generally a function of the wafer geometry; if you want to overclock, then the latest devices will always be likely the fastest.  That is probably true for the 145x series, as they have a speed USB core, so rise and fall times must be well controlled.  I am messing around with these at the moment (1459).  I have also released a board for the 18F27J53, another much larger USB device (128k memory).  Ill send you one plus the 16F1459 Les

top204


See_Mos

Les, thanks for the information about the Q series.  I really should get up to date instead of using the old parts which I have to hand.  Unfortunately the minimum order charge has made it prohibitive if you only need a couple of devices to play with.

Frizie

What is the fastest 8-pin PIC at the moment asked to CoPilot.

Answer number 1:
The fastest 8-pin PICmicro at the moment is the PIC18F010 and PIC18F020 from Microchip Technology. These microcontrollers offer an impressive performance of 10 MIPS (Million Instructions Per Second) and contain 4K bytes of program memory, 256 bytes of RAM, and 64 bytes of EEPROM memory

Asking the same question again, answer number 2:
The fastest 8-pin PICmicro microcontroller is the PIC12F1840 from Microchip Technology. This microcontroller has a maximum clock speed of 32 MHz and offers a wide range of features, including a 10-bit ADC, PWM, and a built-in oscillator1.

Asking the same question again, answer number 3:
The fastest 8-pin PICmicro at the moment is the PIC16F18446 from Microchip Technology. This microcontroller has a maximum clock speed of 32 MHz and offers advanced features such as a 10-bit ADC, multiple PWM modules, and an integrated op-amp1.

Draw your conclusions.
Frizie.
Ohm sweet Ohm | www.picbasic.nl