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

Main Menu

GPT-4 (AI)

Started by Peter Truman, Sep 17, 2023, 12:42 AM

Previous topic - Next topic

Peter Truman

After reading an article about the new version of Chat GPT (GPT-4) I decided to ask a question that I thought would test it a bit.

I asked it to show me the basics of how to encode pocsag messages for pagers - this is what it came back with!

' Define constants for POCSAG parameters
CONST FREQ_ZERO = 1200  ' Frequency for a binary zero
CONST FREQ_ONE = 2200   ' Frequency for a binary one
CONST BAUD_RATE = 1200  ' Baud rate in bits per second

' Function to encode a message into POCSAG format
FUNCTION EncodePOCSAGMessage(message AS STRING, address AS LONG)
    ' Calculate the synchronizing codeword (sync word)
    DIM syncWord AS STRING * 32
    syncWord = "01010101010101010101010101010101"  ' Replace with the actual sync word

    ' Encode the address
    DIM encodedAddress AS STRING * 21
    encodedAddress = BinaryToString(address, 21)

    ' Encode the message
    DIM encodedMessage AS STRING
    FOR i = 1 TO LEN(message)
        DIM charCode AS BYTE
        charCode = ASC(MID(message, i, 1))
        encodedMessage = encodedMessage + BinaryToString(charCode, 7)

    ' Concatenate the sync word, address, and message
    encodedPOCSAG = syncWord + encodedAddress + encodedMessage

    ' Send the encoded POCSAG signal using your hardware's output functions
    ' (This will depend on your specific hardware)

    ' You may also need to modulate the signal to the desired carrier frequency
    ' and control the timing for each bit based on the baud rate

    ' Return the encoded POCSAG signal
    RETURN encodedPOCSAG

' Function to convert a decimal number to binary string with padding
FUNCTION BinaryToString(value AS LONG, width AS BYTE) AS STRING
    DIM binaryStr AS STRING
    FOR i = width - 1 DOWNTO 0
        IF value AND (2 ^ i) THEN
            binaryStr = binaryStr + "1"
            binaryStr = binaryStr + "0"
    RETURN binaryStr

' Example usage
message = "HELLO"
address = 12345
encodedPOCSAG = EncodePOCSAGMessage(message, address)

' Now, you can send the encoded POCSAG signal using your hardware
' and control the modulation and timing as required.

I've not done anything with this - certainly not ready to test it but, at first glance it looks to me like this might be the basis for some useable code?

It's taken me 20 years to be be able to write vauguly useful code - and this thing did in in 15 seconds (plus all the devlolment time thousands of talented programmers put in to build the model :-)

I think we are doomed!


Doomed indeed Peter. I can imagine the answer as to who is responsible for, say, an accident caused by a coding error when the code was written by Chat-GPT. I have just seen a piece on TV where AI generated, fake, videos are creating millions of views and, of course, lots of advertising revenue.

It's not like it used to be!



Wouldn't it be like this ?
Ignorance comes with a cost


Sadly, yes.

Peter Truman

Quote from: keytapper on Sep 18, 2023, 11:02 AMWouldn't it be like this ?
Ha ha yes - I saw that movie. I'm gettin old so the prospect doesn't scare me too much. However, my new Grandson (4 weeks) is going to have to deal with a very different world than most of us!


That scares me, what should we do to avoid such disastrous events.
I'm seeing the evil with it every time I need to have an answer when calling some system, which they put up such answering machine.
Ignorance comes with a cost

Peter Truman

Me too - I just had an argument on my banking app, turns out it was a bot!
speaking of which - my wife just bought an expensive robot vacuum and mop. I thought it would just be an expensive toy, but it turns out if does a fabulous job (apart from not being able to get into the corners or move the furniture around.

This thing has some sort of LIDAR sticking out of the top and an endless array of sensors of one sort or another. I was able to build a virtual map of the house - the base station has a hot water and waste water tank while the machine sucks all the dust into a bigger bag for later disposal.

I had a bag of chips (crisps for those in the UK) while the wife was at work - now I'm certain the vac is going to report my crumbs to her via a txt message!

I did say we were doomed!