Author Topic: Programming Challenge, EEVblog forum people vs ChatGPT  (Read 4053 times)

0 Members and 1 Guest are viewing this topic.

Offline MK14Topic starter

  • Super Contributor
  • ***
  • Posts: 4539
  • Country: gb
Programming Challenge, EEVblog forum people vs ChatGPT
« on: March 31, 2023, 11:25:51 am »
I asked ChatGPT, to write a C program which does something.

N.B.  Running the program, is considered cheating.

Please determine what it will do, by examining it as a human, and working out what it will do.

Polite request:
If you do end up giving up and running it, then please don't spoil it for others, in this thread.

Code: [Select]
#include <stdio.h>

int main() {
    char message[] = {72^1, 97^2, 32^3, 72^4, 97^5, 32^6, 102^7, 111^8, 111^9, 108^10, 101^11, 100^12, 32^13, 121^14, 111^15, 117^16, 32^17, 111^18, 110^19, 32^20, 65^21, 112^22, 114^23, 105^24, 108^25, 32^26, 49^27, 115^28, 116^29, 32^30, 50^31, 48^32, 50^33, 51^34};
    for (int i = 0; i < sizeof(message) / sizeof(char); i++) {
        printf("%c", message[i] ^ (i+1));
    }
    printf("\n");
    return 0;
}

I used two different, online C systems, to confirm correct operation.  These two:

https://www.programiz.com/c-programming/online-compiler/

https://www.w3schools.com/c/tryc.php?filename=demo_compiler
 

Offline MK14Topic starter

  • Super Contributor
  • ***
  • Posts: 4539
  • Country: gb
Re: Programming Challenge, EEVblog forum people vs ChatGPT
« Reply #1 on: March 31, 2023, 11:37:34 am »
Correctly answered by brucehoult, in very rapid time.  (Via PM).

With easily enough of the answer and a perfectly correct explanation, as to how it is working.

10 / 10.
 

Offline Kalvin

  • Super Contributor
  • ***
  • Posts: 2145
  • Country: fi
  • Embedded SW/HW.
Re: Programming Challenge, EEVblog forum people vs ChatGPT
« Reply #2 on: March 31, 2023, 11:45:29 am »
In the spirit of OP's message, I asked ChatGPT what that code does, and it got it right.
 
The following users thanked this post: MK14

Offline MK14Topic starter

  • Super Contributor
  • ***
  • Posts: 4539
  • Country: gb
Re: Programming Challenge, EEVblog forum people vs ChatGPT
« Reply #3 on: March 31, 2023, 12:03:13 pm »
In the spirit of OP's message, I asked ChatGPT what that code does, and it got it right.

I tried that as well, on a much earlier version, and it got it right.

It's amazing that it can read in code and then give sensible explanations on what it will do.

It perhaps in the future will be a bit like having a programming assistant.  Who you can ask them to look at some code for you, and tell you what it does and/or bug correct it and/or improve or modify it for you.

Understanding languages (such as English) is one thing and sort of makes sense, that it can do it.  But programming languages, are another kettle of fish.  Off-hand (my intuition seems to tell me), it shouldn't really be able to do that.  Since understanding programs, should need relatively genuine intelligence, as opposed to 'probabilistic guessing' at what comes next, which many people seem to say, ChatGPT does.
 

Online brucehoult

  • Super Contributor
  • ***
  • Posts: 4036
  • Country: nz
Re: Programming Challenge, EEVblog forum people vs ChatGPT
« Reply #4 on: March 31, 2023, 12:17:07 pm »
A week or so ago I gave it an algorithm in english and asked it to give assembly language for ARM, RISC-V, x86, 6502, z80, PDP-11, MSP430.

There were a couple of minor mistakes, but it was damn close. How???? Without having a bunch of compilers on tap...
 
The following users thanked this post: MK14

Online magic

  • Super Contributor
  • ***
  • Posts: 6779
  • Country: pl
Re: Programming Challenge, EEVblog forum people vs ChatGPT
« Reply #5 on: March 31, 2023, 07:48:30 pm »
So you asked it to design and implement a stream cipher? :D
 
The following users thanked this post: MK14

Online golden_labels

  • Super Contributor
  • ***
  • Posts: 1209
  • Country: pl
Re: Programming Challenge, EEVblog forum people vs ChatGPT
« Reply #6 on: March 31, 2023, 08:39:09 pm »
I will argue ChatGPT wrote code, that fails on EBCDIC systems, to prove I know the answer without revealing it. ;)

How????
Translating a description to code is mostly a language task. Did you never wonder, how all those programmers copy-pasting code from Stack Overflow manage to write working software? ;)

Try asking ChatGPT to predict and handle edge cases and invalid data. If that’s not a common problem or it can’t be split into common problems, or there is not enough code snippets for it to copy from, chances of seeing anything sensible are low. That is because the task is no longer about putting puzzle pieces together.
People imagine AI as T1000. What we got so far is glorified T9.
 
The following users thanked this post: MK14

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14471
  • Country: fr
Re: Programming Challenge, EEVblog forum people vs ChatGPT
« Reply #7 on: March 31, 2023, 09:04:28 pm »
Well, there was some time when "programming" computers, which usually included from translating a high-level software description into machine code, to actually "uploading" said code to the target computer, was a separate and whole job in itself.

With high-level programming languages and decent compilers, this job completely disappeared, and software developers themselves translate their ideas into some programming language. While it's significantly more productive (at least on the surface), mixing both tasks doesn't always work well.

So can this "programming" task now be done by some machine which will just take a very high-level description in natural language? Sure. Somewhat. It will take time before the translation is correct "enough", but that's not the whole issue, as one could argue that humans do usually not write 100% correct programs either.

The main issue is believing that correctly expressing a program's behavior in a natural language is actually possible AND more productive than implementing it in a programming language.

While the hardest part is almost ALWAYS to write correct specifications, and not the implementation itself.
And writing specifications is also the most annoying part usually, way more tedious than actually "programming", which many find fun.
So is this going to be more productive and easier on people? I doubt it. Unless all you want is to "play", which is what people are currently doing with ChatGPT.
They want a toy.
 
The following users thanked this post: MK14

Offline MK14Topic starter

  • Super Contributor
  • ***
  • Posts: 4539
  • Country: gb
Re: Programming Challenge, EEVblog forum people vs ChatGPT
« Reply #8 on: March 31, 2023, 10:05:24 pm »
I will argue ChatGPT wrote code, that fails on EBCDIC systems, to prove I know the answer without revealing it. ;)

How????
Translating a description to code is mostly a language task. Did you never wonder, how all those programmers copy-pasting code from Stack Overflow manage to write working software? ;)

Try asking ChatGPT to predict and handle edge cases and invalid data. If that’s not a common problem or it can’t be split into common problems, or there is not enough code snippets for it to copy from, chances of seeing anything sensible are low. That is because the task is no longer about putting puzzle pieces together.

You're right, about the "fails on EBCDIC systems".  I (and ChatGPT) assumed, certain things, which if they are different, could affect the results.



ChatGPT surprised me, by questioning, my later (I think after this thread was created, or at least the submitted source code, was ready for it).

I asked (the program in this case, was the one in the OP):

Quote
Can you rewrite the program, using blowfish instead.  To make it much harder to decode by hand.

It then replied or queried me, with the response:

Quote
Blowfish is a symmetric-key block cipher that is not suitable for encoding a message character by character, as it operates on fixed-size blocks of data. Therefore, we need to modify the program to use Blowfish in a suitable mode of operation, such as ECB (Electronic Codebook) or CBC (Cipher Block Chaining).

Here is an example of how you can modify the program to use Blowfish encryption in ECB mode:

So, I'm impressed that it appeared to understand things well enough, to query why I wanted to use something which expects the data to be in 64 bit chunks, when the existing program was character orientated.  It also seems to address that issue.

Unfortunately, the programs it came up with, may well have worked on dedicated C compiler (e.g. with terminal, GCC etc) installations.  But was a bit too complicated to easily work with the various online C compiler systems, available on the internet.

Because it wanted to include specific libraries and change the GCC command line (linker) settings, to get it to compile.  Hence it would no longer be a simple cut and paste into any old C online compiler, type of program.  Such as (" #include <openssl/blowfish.h> ") and/or (" #include <crypt.h> ") etc.

Hence " gcc prog.c -lcrypt -o prog ", was its suggested mod, at one point.  But varying online C compiler characteristics, put me off from going in that direction.
« Last Edit: March 31, 2023, 10:07:45 pm by MK14 »
 

Online golden_labels

  • Super Contributor
  • ***
  • Posts: 1209
  • Country: pl
Re: Programming Challenge, EEVblog forum people vs ChatGPT
« Reply #9 on: April 01, 2023, 01:07:10 am »
You're right, about the "fails on EBCDIC systems".  I (and ChatGPT) assumed, certain things, which if they are different, could affect the results.
I said that only to indicate, I know the answer, without spoiling the fun to others. I do not expect it to work on EBCDIC or other exotic encodings, or to either you or the smortnet care about that. :)
People imagine AI as T1000. What we got so far is glorified T9.
 
The following users thanked this post: MK14

Offline Simon

  • Global Moderator
  • *****
  • Posts: 17815
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Programming Challenge, EEVblog forum people vs ChatGPT
« Reply #10 on: April 01, 2023, 08:23:32 am »
If you want to challenge chatGPT ask it so set up a micro controller peripheral. I tried asking it to set up the uart on a SAMC21, it started trying to identify register addresses for pins where there is a group of registers with one per pin by dividing the pin number by 32. I pointed this was incorrect, so it apologized and did the modulo instead. I pointed out that this was superfluous, it once again apologized and repeated the code that divided by 32 instead with a modulo thrown in for good measure.

Glad to hear my job is not at stake for the next 100 years :)

 

Offline MK14Topic starter

  • Super Contributor
  • ***
  • Posts: 4539
  • Country: gb
Re: Programming Challenge, EEVblog forum people vs ChatGPT
« Reply #11 on: April 01, 2023, 09:02:03 pm »
If you want to challenge chatGPT ask it so set up a micro controller peripheral. I tried asking it to set up the uart on a SAMC21, it started trying to identify register addresses for pins where there is a group of registers with one per pin by dividing the pin number by 32. I pointed this was incorrect, so it apologized and did the modulo instead. I pointed out that this was superfluous, it once again apologized and repeated the code that divided by 32 instead with a modulo thrown in for good measure.

Glad to hear my job is not at stake for the next 100 years :)

I was expecting to have to make massive excuses, as to why ChatGPT, is not anywhere near, ready for such things.  Yet when I tried it, with your problem (or part of your problem), it had a nice bash at it.

From your post, my question from it to ChatGPT was:
Quote
set up the uart on a SAMC21

Its response, including some code sections, was:
Code: [Select]
Sure, here are the steps to set up UART on a SAMC21 microcontroller:

    Enable the UART module clock by writing to the relevant bit in the PM_APBCMASK register.

    rust

PM->APBCMASK.reg |= PM_APBCMASK_SERCOMX;

Replace "X" with the number of the SERCOM peripheral you want to use for UART.

Configure the pins for UART communication. You need to set the pin multiplexing for the SERCOM peripheral you are using, and configure the corresponding pins as either input or output. You can do this using the PINCFG and PMUX registers.

For example, if you want to use SERCOM1 for UART and configure PA16 as TX and PA17 as RX:

less

// Enable the peripheral multiplexer for PA16 and PA17
PORT->Group[0].PINCFG[16].bit.PMUXEN = 1;
PORT->Group[0].PINCFG[17].bit.PMUXEN = 1;

// Set the pin multiplexing to use SERCOM1 for PA16 and PA17
PORT->Group[0].PMUX[8].reg |= PORT_PMUX_PMUXE_C;

// Set the direction of the pins
PORT->Group[0].DIRSET.reg = PORT_PA16;
PORT->Group[0].DIRCLR.reg = PORT_PA17;

Configure the UART module. You need to set the baud rate, data format (parity, number of bits, stop bits), and enable the UART transmitter and/or receiver. You can do this using the SERCOM_USART_CTRLA, SERCOM_USART_CTRLB, SERCOM_USART_BAUD, and SERCOM_USART_INTENSET registers.

For example, if you want to use SERCOM1 for UART with a baud rate of 9600, 8 data bits, no parity, and 1 stop bit:

scss

// Reset the SERCOM1 module
SERCOM1->USART.CTRLA.reg = SERCOM_USART_CTRLA_SWRST;
while (SERCOM1->USART.CTRLA.bit.SWRST);

// Configure the UART mode
SERCOM1->USART.CTRLA.reg = SERCOM_USART_CTRLA_MODE_USART_INT_CLK |
                           SERCOM_USART_CTRLA_RUNSTDBY;
SERCOM1->USART.CTRLB.reg = SERCOM_USART_CTRLB_RXEN | SERCOM_USART_CTRLB_TXEN |
                           SERCOM_USART_CTRLB_CHSIZE(0);

// Set the baud rate
uint64_t baud = (uint64_t)(65536 * (1 - 16 * (double)9600 / (double)48000000));
SERCOM1->USART.BAUD.reg = (uint16_t)baud;

// Enable interrupts for RX complete and error
SERCOM1->USART.INTENSET.reg = SERCOM_USART_INTENSET_RXC | SERCOM_USART_INTENSET_ERROR;

Implement the interrupt handler for UART. When data is received or an error occurs, an interrupt will be triggered. You can implement the handler to read the received data or handle the error.

For example, if you want to implement the handler for SERCOM1:

arduino

    void SERCOM1_Handler(void)
    {
        if (SERCOM1->USART.INTFLAG.bit.RXC)
        {
            // Handle received data
            uint8_t data = SERCOM1->USART.DATA.reg;
            // ...
        }
        else if (SERCOM1->USART.INTFLAG.bit.ERROR)
        {
            // Handle error
            // ...
        }
    }

That's it

For straight forward, programming (e.g. in C or Python), I can understand why ChatGPT (and similar tools), can help improve he process.  But automating (auto-generating) some of the work, and some of its analysis, might be helpful, or at least save time, as well.

But for complicated embedded systems, made out of fully custom, PCB/circuit designs, with lots of requirements.  Things like ChatGPT, are more of a fun or toy, way of doing it, at the moment.

Analogy:
A quick glance at its current embedded electronics, software capabilities.  Would seem to show, it would be like hiring an assistant (human), who is so inexperienced, untrained and low knowledge, about such things.  That their attempts at helping one out, could actually end up, wasting a lot more time, than it saves.

Except that in the case of the human assistant.  If they show good promise for the future, and are keen to learn.  Then getting them to help out for a number of months, may yield good payback in the future.  As they gain more and more experience, and need less and less time consuming help.

Whereas ChatGPT, wouldn't be learning or improving, if used for such things.  So there would not be a return in the longer term, on extra time needed to cope with ChatGPTs shortcomings.
« Last Edit: April 01, 2023, 09:04:00 pm by MK14 »
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 17815
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Programming Challenge, EEVblog forum people vs ChatGPT
« Reply #12 on: April 02, 2023, 08:45:45 pm »
Code: [Select]
#include "sam.h"

#define UART_SERCOM             SERCOM0
#define UART_TX_PIN             PIN_PA04
#define UART_RX_PIN             PIN_PA05
#define UART_MUX_SETTING        0x01

#define UART_BUFFER_SIZE        128

volatile char uart_rx_buffer[UART_BUFFER_SIZE];
volatile uint8_t uart_rx_head = 0;
volatile uint8_t uart_rx_tail = 0;

void uart_init(void) {
    // Enable clock to SERCOM0 peripheral module
    PM->APBCMASK.reg |= PM_APBCMASK_SERCOM0;

    // Configure SERCOM0 for UART communication
    GCLK->PCHCTRL[SERCOM0_GCLK_ID_CORE].reg = GCLK_PCHCTRL_GEN_GCLK0_Val | GCLK_PCHCTRL_CHEN;
    UART_SERCOM->USART.CTRLA.reg = SERCOM_USART_CTRLA_MODE_USART_INT_CLK |
                                   SERCOM_USART_CTRLA_RXPO(UART_RX_PIN / 2) |
                                   SERCOM_USART_CTRLA_TXPO(UART_TX_PIN / 2);
    UART_SERCOM->USART.CTRLB.reg = SERCOM_USART_CTRLB_RXEN | SERCOM_USART_CTRLB_TXEN | SERCOM_USART_CTRLB_RXMODE;
    UART_SERCOM->USART.BAUD.reg = (uint16_t)(SystemCoreClock / (16 * 9600));

    // Configure GPIO pins for UART
    PORT->Group[UART_TX_PIN / 32].PINCFG[UART_TX_PIN % 32].bit.PMUXEN = 1;
    PORT->Group[UART_TX_PIN / 32].PMUX[UART_TX_PIN % 32 >> 1].bit.PMUXE = UART_MUX_SETTING;
    PORT->Group[UART_RX_PIN / 32].PINCFG[UART_RX_PIN % 32].bit.PMUXEN = 1;
    PORT->Group[UART_RX_PIN / 32].PMUX[UART_RX_PIN % 32 >> 1].bit.PMUXO = UART_MUX_SETTING;

    // Enable RX interrupt
    UART_SERCOM->USART.INTENSET.reg = SERCOM_USART_INTENSET_RXC;
    NVIC_EnableIRQ(SERCOM0_IRQn);
}

void uart_write(char *data, uint32_t length) {
    for (uint32_t i = 0; i < length; i++) {
        while (!(UART_SERCOM->USART.INTFLAG.reg & SERCOM_USART_INTFLAG_DRE));
        UART_SERCOM->USART.DATA.reg = data[i];
    }
}

void SERCOM0_Handler(void) {
    if (UART_SERCOM->USART.INTFLAG.reg & SERCOM_USART_INTFLAG_RXC) {
        char data = (char)UART_SERCOM->USART.DATA.reg;
        uint8_t next_tail = (uart_rx_tail + 1) % UART_BUFFER_SIZE;
        if (next_tail != uart_rx_head) {
            uart_rx_buffer[uart_rx_tail] = data;
            uart_rx_tail = next_tail;
        }
    }
}

int main(void) {
    SystemInit();
    uart_init();

    char message[] = "Hello, world!\r\n";
    uart_write(message, sizeof(message) - 1);

    while (1) {
        if (uart_rx_head != uart_rx_tail) {
            char data = uart_rx_buffer[uart_rx_head];
            uart_rx_head = (uart_rx_head + 1) % UART_BUFFER_SIZE;
            // Do something with received data
        }
    }

    return 0;
}

ME: can you generate generic setup functions for a TCC with dead time

Code: [Select]
#include "sam.h"

#define TCC_MODULE          TCC0
#define TCC_CLOCK_SOURCE    GCLK_GENERATOR_0
#define TCC_PRESCALER       TCC_CTRLA_PRESCALER_DIV1
#define TCC_PERIOD          0xFFFF

#define TCC_OUTPUT1_PIN     PIN_PA08E_TCC0_WO0
#define TCC_OUTPUT2_PIN     PIN_PA09E_TCC0_WO1

#define TCC_DEAD_TIME_NS    1000

void tcc_init(void) {
    // Enable clock to TCC0 peripheral module
    PM->APBCMASK.reg |= PM_APBCMASK_TCC0;

    // Configure TCC0 for dead-time generation
    GCLK->PCHCTRL[TCC_CLOCK_SOURCE].reg = GCLK_PCHCTRL_GEN_GCLK0_Val | GCLK_PCHCTRL_CHEN;
    TCC_MODULE->CTRLA.reg = TCC_CTRLA_PRESCALER(TCC_PRESCALER) | TCC_CTRLA_ENABLE;
    TCC_MODULE->PER.reg = TCC_PERIOD;
    TCC_MODULE->WAVE.reg = TCC_WAVE_WAVEGEN_NPWM;
    TCC_MODULE->DRVCTRL[0].reg = TCC_DRVCTRL_NRV(0) | TCC_DRVCTRL_NRE(0) |
                                  TCC_DRVCTRL_NRV(1) | TCC_DRVCTRL_NRE(1);
    TCC_MODULE->DRVCTRL[1].reg = TCC_DRVCTRL_NRV(2) | TCC_DRVCTRL_NRE(2) |
                                  TCC_DRVCTRL_NRV(3) | TCC_DRVCTRL_NRE(3);
    TCC_MODULE->CC[0].reg = 0;
    TCC_MODULE->CC[1].reg = 0;
    TCC_MODULE->CC[2].reg = 0;
    TCC_MODULE->CC[3].reg = 0;
    TCC_MODULE->DBCTRL.reg = TCC_DBCTRL_FILTERVAL((uint16_t)(TCC_DEAD_TIME_NS * (SystemCoreClock / 1000000) / 1000 - 1)) |
                               TCC_DBCTRL_OUTVAL(0) |
                               TCC_DBCTRL_DBLDRE(1);
    TCC_MODULE->EVCTRL.reg = TCC_EVCTRL_OVFEO | TCC_EVCTRL_MCEO0 | TCC_EVCTRL_MCEO1;
    TCC_MODULE->INTENSET.reg = TCC_INTENSET_OVF | TCC_INTENSET_MC0 | TCC_INTENSET_MC1;
    NVIC_EnableIRQ(TCC0_IRQn);

    // Configure TCC0 output pins
    PORT->Group[TCC_OUTPUT1_PIN / 32].WRCONFIG.reg = PORT_WRCONFIG_HWSEL |
                                                     PORT_WRCONFIG_WRPINCFG |
                                                     PORT_WRCONFIG_WRPMUX |
                                                     PORT_WRCONFIG_PMUX(TCC_OUTPUT1_PIN % 32 >> 1) |
                                                     PORT_WRCONFIG_PMUXEN |
                                                     PORT_WRCONFIG_PINMASK(1 << (TCC_OUTPUT1_PIN % 32));
    PORT->Group[TCC_OUTPUT2_PIN / 32].WRCONFIG.reg = PORT_WRCONFIG_HWSEL |
                                                     PORT_WRCONFIG_WRPINCFG |
                                                     PORT_WRCONFIG_WRPMUX |
                                                     PORT_WRCONFIG_PMUX(TCC_OUTPUT2_PIN % 32 >> 1) |
                                                     PORT_WRCONFIG_PMUXEN |
                                                     PORT_WRCONFIG_PINMASK(1 << (TCC_OUTPUT2_PIN % 32));
}


me: what is the value of "PIN_PA04"

GPT: The value of PIN_PA04 depends on the specific microcontroller being used and the pin mapping defined in its header file.

In general, PIN_PA04 is a constant that represents the pin number of a specific pin on the microcontroller. The PA prefix indicates that this pin is part of port A, and the 04 suffix indicates that it is the 4th pin in that port.

For example, in the header file for the Atmel SAMC21J18A microcontroller, PIN_PA04 is defined as:

c
Copy code
#define PIN_PA04  ( 4ul) /**< \brief Pin Number for PA04 */
This indicates that PIN_PA04 has a value of 4. However, the actual value used may be different depending on the specific microcontroller and pin mapping.

me:
the code you show divides this value by 32, any pin number will not exceed 31 so the result will always be "0" this is not a method that can be used to pinpoint the register of a port.

GPT: You are correct, my previous response was incorrect. Dividing the pin number by 32 will always result in 0 for pins numbered 0-31. I apologize for the confusion.

To get the correct index of the PORT register for a pin, you can use the pin number modulo 32. For example, if PIN_PA04 is defined as 4:

Code: [Select]
uint32_t port_index = PIN_PA04 / 32;
uint32_t port_pin_index = PIN_PA04 % 32;

PORT->Group[port_index].DIRSET.reg = 1 << port_pin_index;

me: No it does not, if you take the modulo of a number from 0 to 31 divided by 32 the result will always be that number. So the modulo calculation does not actually do anything but give you back the number you started with.

GPT: You are correct, I apologize for the confusion. Taking the modulo of a pin number from 0 to 31 divided by 32 will always result in the same number. My previous response was incorrect.

To access the corresponding bit in the PORT register for a given pin, you can use bitwise operators to set or clear the bit. For example, to set the direction of a pin to output, you can use the following code:

Code: [Select]
#define PIN_PA04 4

uint32_t pin_mask = 1UL << (PIN_PA04 % 32);
PORT->Group[PIN_PA04 / 32].DIRSET.reg = pin_mask;


me: I am afraid that the last response is also incorrect, you have again used a modulo calculation that yields the number you started with because you are dividing the pin number by 32 when the number will never be higher than 31. You then again do the same number divided by 32 which as the number will never be higher than 31 will always yield 0

GPT: You are correct, I apologize for my mistake. I misunderstood your question and provided incorrect information.

If the pin number is less than or equal to 31, you can access the corresponding bit in the PORT register directly using the bit position of the pin in the register. The formula for calculating the bit position is:

Code: [Select]
pin_position = pin_number % 32



 
The following users thanked this post: MK14

Offline MK14Topic starter

  • Super Contributor
  • ***
  • Posts: 4539
  • Country: gb
Re: Programming Challenge, EEVblog forum people vs ChatGPT
« Reply #13 on: April 02, 2023, 10:01:47 pm »
I've heard from a number of sources (and I think, even discovered it, myself), that the current/free ChatGPT (Version before or at 3.5 or whatever), is troubled by mathematics.  Even maths which would be quite easy for many humans.

But the later ChatGPT 4.0, which currently (I've heard) is only available for paid versions (or some other sources, such as Microsoft Bing, in some cases, and maybe some websites, that pay for the API, which uses 4.0).  Which (reportedly, as I've not used it, myself, knowingly, except maybe via bing), is considerably better at mathematics.  So presumably, would resolve the issues, you have found with it.

Two things I'm uncertain about.
Firstly, if version 4.0 will be released (As ChatGPT) version 4.0, sooner or later.  Or will it always be subscription only?

Secondly, if version 4.0 (or the full release of version 4.0 on onwards), is released to everyone, if they pay for it.

As early rumours, were that it was on restricted release, until they had finished testing and preventing it doing unwarranted (unsafe etc), things.

Also in the pipeline, are more advanced things, such as being able to feed into it, your own images.  Such as diagrams, of what you intend for it to write for you.  Such as complete websites.  But it is not clear when, or how (free or paid), that will happen.

They do seem to be saying that later versions (4.0 and later), show much less mistakes, compared to the current (free) version.  Also, that it is better able to produce, fully working programs (I'm not 100% sure, but reading between the lines, that would seem to be the case, at least for some things, like working website implementations, of at least a small working size).

Disclaimer:
The people/companies behind ChatGPT use to be very free and open, with information and activities, etc.

But recently, they have decided, to go almost completely silent, and take a significantly different business approach.

I find that behaviour extremely surprising, given Microsoft's, significant involvement in the projects/business (possible sarcasm in this sentence.   :-DD  )

Really, I think their sudden silence and change of business attitudes, will just mean that other (friendlier, and more helpful etc) companies, will gain greater market penetration.  I.e. They could end up shooting themselves in the foot.
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 17815
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Programming Challenge, EEVblog forum people vs ChatGPT
« Reply #14 on: April 03, 2023, 05:11:10 pm »
chatGPT cannot be free. The cost of running it will mount up both in resources to create and advance it and hardware + power to run it. With the seemingly spectacular results it can produce who would just give it away?
 
The following users thanked this post: MK14

Offline MK14Topic starter

  • Super Contributor
  • ***
  • Posts: 4539
  • Country: gb
Re: Programming Challenge, EEVblog forum people vs ChatGPT
« Reply #15 on: April 03, 2023, 05:33:16 pm »
chatGPT cannot be free. The cost of running it will mount up both in resources to create and advance it and hardware + power to run it. With the seemingly spectacular results it can produce who would just give it away?

I don't want to go into the specific details or projects.  But, there has been similar stuff before, and it continued to be free (and open-source), to this day.

It was funded, by people, like yourself (if I remember correctly).

Who joined (and allowed some of their computer resources to be used, for free), multi-computer resource sharing facilities, such as bionic and many other such things, which was used to create the computer intensive parts of it.

Some are for medical research, some are for AI related things.  If I understand the stuff, correctly.

EDIT:  To avoid confusion.  What you 'funded' (allowed some of your computer resources to be used for), was for medical research (if I remember, correctly).  But, there have been similar such projects, which use the computer resources, for AI (and similar/related subject areas, such as strategy games).
« Last Edit: April 03, 2023, 05:45:05 pm by MK14 »
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 17815
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Programming Challenge, EEVblog forum people vs ChatGPT
« Reply #16 on: April 03, 2023, 05:46:46 pm »
BOINC which I do run does not work in real time. There is real time distributed computing where work is actively divvied up and sent over a local network for fast turn around. BOINC works on the principle of tasks being broken down and queued for transmission to multiple machines so that should one fail to return or the work not complete properly there are still valid results and there is a bit of majority vote on a work unit coming back mangled due to the redundancy they can afford. So I don't think a distributed system like boinc would be capable of such real time response. Unless of course something new was created for this task. But I believe that these chat bots need a huge amount of data available to them which probably won't go onto a hard drive on a common computer and the bandwidth would be too small over the internet.

At commercial levels no one will want to send their software anywhere outside of their own server farms. I don't know what this stuff runs on, can a graphics card do any of this. Fill a server rack with GPU's and that is some computing power there that will take energy.
 
The following users thanked this post: MK14

Offline MK14Topic starter

  • Super Contributor
  • ***
  • Posts: 4539
  • Country: gb
Re: Programming Challenge, EEVblog forum people vs ChatGPT
« Reply #17 on: April 03, 2023, 06:00:37 pm »
BOINC which I do run does not work in real time. There is real time distributed computing where work is actively divvied up and sent over a local network for fast turn around. BOINC works on the principle of tasks being broken down and queued for transmission to multiple machines so that should one fail to return or the work not complete properly there are still valid results and there is a bit of majority vote on a work unit coming back mangled due to the redundancy they can afford. So I don't think a distributed system like boinc would be capable of such real time response. Unless of course something new was created for this task. But I believe that these chat bots need a huge amount of data available to them which probably won't go onto a hard drive on a common computer and the bandwidth would be too small over the internet.

At commercial levels no one will want to send their software anywhere outside of their own server farms. I don't know what this stuff runs on, can a graphics card do any of this. Fill a server rack with GPU's and that is some computing power there that will take energy.

That is a good point.

My rough/approximate understanding (there seem to be a number of people on this forum, who have made threads and posts about the specific details, on this forum, already), is that the AI training (which is a massive job).   Is either done by some organisation or by lots of volunteers, on their donated computer time.  E.g. Using their graphics cards.

Which results in a massive download (typical figures, mentioned, seem to be like 77 GB of stuff).

Once you have the 77 GB (exact sizes, vary a lot, and depend on which AI system, you are using), on your computer.  You can either use a powerful, modern graphics card, with enough minimum vram size, to answer your ChatGPT like question (or image drawing or AI stuff), perhaps in a matter of some seconds, to get an answer.

Or do it without a graphics card, just on the CPU.  But that can easily take (reportedly) minutes, even on a very fast computer.

But some places, allow people for free, to access their computer systems, which already have access to those training databases.

I don't know how they are funded.

In a related (but different, sense) Google (and other companies), web searches (not ChatGPT) need massive databases, and significant computing resources, and are usually free.  But they seem to fund themselves, by selling advertising and other data related monetary avenues.

I agree, better AI systems, may well need the end users to pay money, to use them.  It is just that I don't trust Microsoft, and any charges they are making.

So if a trustworthy company, makes fair and reasonable charges.  I guess that would be ok.
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 17815
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Programming Challenge, EEVblog forum people vs ChatGPT
« Reply #18 on: April 03, 2023, 07:21:18 pm »
Yes if it's something that can run as a single user on a PC sure. I don't know how big these things are. I'm also rather confused. ChatGPT is a language model chat bot that is designed to interact like a human, so why is everyone trying to get it to write code? It feels like the sodding arduino all over again.
 
The following users thanked this post: MK14

Offline MK14Topic starter

  • Super Contributor
  • ***
  • Posts: 4539
  • Country: gb
Re: Programming Challenge, EEVblog forum people vs ChatGPT
« Reply #19 on: April 03, 2023, 09:22:13 pm »
Yes if it's something that can run as a single user on a PC sure. I don't know how big these things are. I'm also rather confused. ChatGPT is a language model chat bot that is designed to interact like a human, so why is everyone trying to get it to write code? It feels like the sodding arduino all over again.

Yes, that is a good point and I agree with you, assuming I understand what you mean.

If by Arduino, you mean people thinking they can write good quality, useful programs, with little or no, actual knowledge, experience or training in proper programming.  Hence potentially writing software, which is not the best of quality, or bug free.

Then publish their creations and make libraries full of it, available throughout the internet.  So, that others can enjoy the bugs, misconceptions, faults, comment weakness etc.

On the other hand.  Ultimately, maybe it (ChatGPT and similar) could act like a top of the range, highly experienced, and very good quality software engineers, that can exist.  Hence, actually improving the quality of software, that exists.

I suspect part of the problem with the Arduino software (which I don't know that much about, anyway).  Is the relative lack of quality control, so that just about anyone can write code for it and publish it.  Which can lead to some rather poor quality code, being used by some people.

I've never really been able to properly understand how an Arduino, with just 2k of ram, could succeed, like it has.
 

Online brucehoult

  • Super Contributor
  • ***
  • Posts: 4036
  • Country: nz
Re: Programming Challenge, EEVblog forum people vs ChatGPT
« Reply #20 on: April 03, 2023, 10:39:45 pm »
I've never really been able to properly understand how an Arduino, with just 2k of ram, could succeed, like it has.

216384 states ought to be enough for anyone!
 
The following users thanked this post: MK14, Microdoser

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14471
  • Country: fr
Re: Programming Challenge, EEVblog forum people vs ChatGPT
« Reply #21 on: April 03, 2023, 10:52:29 pm »
Yes if it's something that can run as a single user on a PC sure. I don't know how big these things are. I'm also rather confused. ChatGPT is a language model chat bot that is designed to interact like a human, so why is everyone trying to get it to write code? It feels like the sodding arduino all over again.

That's documented. While GPT-3 could be run on a reasonably powerful PC, I've read that ChatGPT 4 would require resources that are completely out of reach for a PC: several hundreds of GB of RAM and about the required storage, I don't even know for sure, it's said to be in the order of hundreds of TB or model data.
 
The following users thanked this post: MK14

Offline Simon

  • Global Moderator
  • *****
  • Posts: 17815
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Programming Challenge, EEVblog forum people vs ChatGPT
« Reply #22 on: April 04, 2023, 06:52:54 pm »
Yes if it's something that can run as a single user on a PC sure. I don't know how big these things are. I'm also rather confused. ChatGPT is a language model chat bot that is designed to interact like a human, so why is everyone trying to get it to write code? It feels like the sodding arduino all over again.

Yes, that is a good point and I agree with you, assuming I understand what you mean.

If by Arduino, you mean people thinking they can write good quality, useful programs, with little or no, actual knowledge, experience or training in proper programming.  Hence potentially writing software, which is not the best of quality, or bug free.

Then publish their creations and make libraries full of it, available throughout the internet.  So, that others can enjoy the bugs, misconceptions, faults, comment weakness etc.

On the other hand.  Ultimately, maybe it (ChatGPT and similar) could act like a top of the range, highly experienced, and very good quality software engineers, that can exist.  Hence, actually improving the quality of software, that exists.

I suspect part of the problem with the Arduino software (which I don't know that much about, anyway).  Is the relative lack of quality control, so that just about anyone can write code for it and publish it.  Which can lead to some rather poor quality code, being used by some people.

I've never really been able to properly understand how an Arduino, with just 2k of ram, could succeed, like it has.

If you look at the tag line for the Arduino it talks about hackers, makers and artists. And yet it is misused in serious applications. In the same way chatGPT does not describe itself as a programmers assistance but even I have only tried it out as such.
 

Offline AndyBeez

  • Frequent Contributor
  • **
  • Posts: 856
  • Country: nu
Re: Programming Challenge, EEVblog forum people vs ChatGPT
« Reply #23 on: April 04, 2023, 08:14:36 pm »
For me, the AI debate is not about what it actually is but, what actual useful stuff can we do with it?

The story of tech is littered with the wreckage of solutions that were looking for a problem. Remember how the blockchain was going to change everything? ML and AI are great tools for digesting big data, but using them as replacements for human creativity and ingenuity, no. Tools for improving, maybe yes. My observation about ChatGPT is one can regard it as being the Great Guessing Machine. Which proves Searle's eponymous Chinese Box Conundrum. Ergo, a computer cannot actually think because a computer cannot actually understand. https://en.wikipedia.org/wiki/Chinese_room

Nevertheless, governmental advisers are proclaiming citizen's problems are solved if they trust and invest [heavily] in AI. Equally, other experts with other axes to grind, are accusing the tech sector of witchcraft. On this note, British tech entrepreneur Martha Lane-Fox sounded a note of caution on the accelerated growth of AI hysteria: https://www.silicon.co.uk/e-innovation/artificial-intelligence/lane-fox-ai-504820

Meanwhile In Gotham City...

SwiftUI guru Paul Hudson does an interesting 'teardown' of ChatGPT with a simple task of programming a ticking clock. [ For those unfamiliar with SwiftUI, it is Apple's cross platform language for creating iOS user interfaces] He makes some very important observations about the capabilities of ChatGPT. So students using ChatGPT for their coding projects be warned, your brain still has to be in the room.

Can ChatGPT write better SwiftUI code than you?
« Last Edit: April 04, 2023, 08:36:57 pm by AndyBeez »
 
The following users thanked this post: MK14


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf