News:

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

Main Menu

Artificial intelligence is evolving

Started by gevv, Dec 17, 2022, 03:29 PM

Previous topic - Next topic

gevv

Hello,

My question; Can you write the proton basic code for the 1 hour timer? I will use PIC12F675 microcontroller

The answer of artificial intelligence;

// set registers
TRISIO = 0b11111000; // set GPIO to input
OPTION_REG = 0b10000010; // TMR0 clock source set to internal instruction cycle clock (Fosc/4)
INTCON = 0b00100000; // enable TMR0 interrupt

// main loop
while(1) {
    // start timer
    TMR0 = 0; // clear timer
    T0IE = 1; // enable TMR0 interrupt
    GIE = 1; // enable global interrupts

    // wait for 1 hour
    while(timer_flag == 0); // wait for timer flag to be set

    // reset timer
    TMR0 = 0; // clear timer
    T0IE = 0; // disable TMR0 interrupt
    GIE = 0; // disable global interrupts
    timer_flag = 0; // reset timer flag
}

// timer interrupt service routine
void interrupt ISR(void) {
    if (T0IF == 1) {
        TMR0 = 0; // clear timer
        T0IE = 0; // disable TMR0 interrupt
        GIE = 0



2



Can you write the proton basic compilers code for the 1 hour timer? I will use PIC12F675 microcontroller

#include <p18f4520.h>

// CONFIG
#pragma config FOSC = INTOSCIO_EC // Internal Oscillator, port function on RA6 & RA7
#pragma config WDTE = OFF        // Watchdog Timer Disabled
#pragma config PWRTE = OFF       // Power-up Timer Disabled
#pragma config MCLRE = OFF       // MCLR Pin Function is Digital Input
#pragma config CP = OFF          // Code Protection Disabled
#pragma config CPD = OFF         // Data Code Protection Disabled
#pragma config BOREN = OFF       // Brown-out Reset Disabled
#pragma config IESO = OFF        // Internal External Switchover Disabled
#pragma config FCMEN = OFF       // Fail-Safe Clock Monitor Disabled

#define _XTAL_FREQ 8000000      // Set Clock Frequency to 8MHz

// Variables
unsigned int count = 0;

// Interrupt Service Routine
void interrupt isr(void)
{
    if (TMR0IF == 1) // Check if Timer 0 Over




3

Can you write the proton basic ide code for the 1 hour timer? I will use PIC12F675 microcontroller


// Timer1 Initialization
T1CON = 0b00000100; // Timer1 ON, 8-bit timer, 1:2 prescaler
TMR1H = 0xE0; // Timer1 High byte = 0xE0
TMR1L = 0x00; // Timer1 Low byte = 0x00

// Timer1 Interrupt Initialization
INTCON = 0b11000000; // Enable TMR1 Interrupt and Global Interrupt
PIE1 = 0b00000001; // Enable TMR1 Interrupt

// Main Code
void main(){
    while(1){
        if (INTCONbits.TMR0IF == 1){
            // Timer1 interrupt flag set
            INTCONbits.TMR1IF = 0; // Reset Timer1 Interrupt Flag
            // Do something after 1 hour
        }
    }
}



4


Can you write the picbasic code for the 1 hour timer? I will use PIC12F675 microcontroller


QuoteBelow is the code for the 1 hour timer using the PIC12F675 microcontroller:

;***************************************************************
;  1 Hour Timer
; ***************************************************************

DEVICE  PIC12F675

ORG     0  ; Reset vector
GOTO    main

ORG     4  ; Interrupt vector
GOTO    isr

;***************************************************************
; Declare Variables
;***************************************************************
CBLOCK  0x20
        count
        endc

;***************************************************************
; Main Program
;***************************************************************
main:
    BSF     STATUS,RP0 ; Bank 1
    BCF     INTCON,GIE ; Disable interrupts
    BCF     INTCON,T0IE ; Disable timer interrupt
    MOVLW   0x07 ; Set WREG to 0x07
    MOVWF   OPTION_REG ; Set prescaler to 256
    MOVLW   0xFF ; Set WREG to 0xFF
    MOVWF   count ; Set count to 0xFF
    BSF     INTCON,T0IE ; Enable timer


You can try by signing up on the Playground website https://beta.openai.com/playground
 

RGV250

I have to wonder who is interested in these things, at work a company had software that you took a piece of code and then told it what display and CPU you were using and the absolute garbage it spewed out was awful. It might have worked but when it went wrong it was all but impossible to decipher to fix.
I think most of us like the challenge and especially the older ones amongst us, it is the challenge to keep the brain cells active.
Going a step forward, why would I buy a crossword puzzle that solved itself.
If this is the future then heaven help us.

Bob

trastikata

Quote from: RGV250 on Dec 17, 2022, 06:07 PMI have to wonder who is interested in these things....

My observation is that some of the news content on sites like MS and Yahoo is bot created following the story narrative and trends given by the interested party and then disseminated to many other secondary sites in order to give it a seemingly credibility by the mass numbers.

tumbleweed

QuoteThe answer of artificial intelligence;
Now if only it was smart enough to tell you that none of those examples will get you a 1 hour timer...

top204

Unfortunately, this AI nonsense is actually starting to be taken seriously and used in "real world" scenarios. Humans are a very stupid species of ape, but never before in their evolution have they been more stupid. :-)

As dad used to say to me, "You are clever Leslie, but you do not have much common sense". LOL And now, others with no common sense are in charge of the world and pushing technologies that are not even near completion, and should never have been conceived of in the first place because they will bring nothing but misery and disaster to the already weak civilisations of humans.

HAL

If this AI application, even if it worked, seems much more trouble than it's worth.  Writing a paragraph in fine detail to accomplish a task which can be accomplished in three lines of Positron basic makes one wonder why anyone would bother.  If the AI application is designed to kill any sense of accomplishment that one gets from successfully writing a working program, then I suggest they are a very long way from that goal.  That aside, I believe there are most of us who prefer the "normal" route of learning to program using Positron.  This is not a rant!!! ;)  ;)     

ken_k

Love AI or hate AI it is evolving and we will have to live with it.
Most long journeys start with the first small steps.
I guess the question is will we like it when we get to the destination?
Will our mobile phones sit listening to us and decide to take appropriate action.
Will the smart aleck toaster answer back?
Will the human species make old bones?
Merry Christmas everybody!

keytapper

#7
The last one is the most favorable an reciprocated to You, Ken.

EDIT
Sorry to hijacked the thread.
Ignorance comes with a cost

HAL


If I may echo Ken, Merry Christmas to everyone!!!

And here's hoping for a happy new year as well!  ;)


Stephen Moss

Quote from: ken_k on Dec 22, 2022, 12:01 AMLove AI or hate AI it is evolving and we will have to live with it.
It is already imbedded in so may things around us, fridges that remind you need to replace items, Amazon Alexa and other so called smart devices, self parking cars and the possibility of self driving cars/deliver drones. There is no excaping it without relocating to a small remote island.

As long as I can be contianed small devices with limited capabilities I think we will be safe from it evolving into Skynet, but beware the rise of talkie toaster

HAL

It seems that we could apply the term AI to the search engines that we use many times each day.  Fortunately, the toaster has not said a word as yet.  The washing machine manual claims ability to use the WiFi but requires the owner to enable that feature.  I do have a networked printer but it hasn't said anything either...  :)  :) 

I figure that when appliances talk they will probably all do so at the same time, creating a chaotic situation.  Then I will need to put in ear plugs and start pulling electrical plugs.  Just joking of course.  ;)

Certainly AI will become a useful tool, but I fear that introduction of flawed examples will give it a bad name and turn it into a joke...

My two pennies worth.


keytapper

In my POW it's like the Terminator movies.
I think nobody likes a canned life, where even a small mistake it wouldn't be accepted, like inputting some fields on online forms, nowadays.
Ignorance comes with a cost