Learning to use AI

Learning to use AI

Home Forums The Tea Room Learning to use AI

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #818040
    IanT
    Participant
      @iant

      I’m not a programmer but do enjoy working with my MMB based systems, finding the Picomite family more than capable of meeting my needs.

      Last year, I had a a problem I didn’t know how to solve last year (needed an algorithm) but found a chunk of Arduino code that seemed to fit the bill. I guess I could have used just an Arduino but that would have involved re-learning Arduino to code the rest and using new hardware, when I already had a very capable platform to hand.

      So I asked GROK to translate the code for me. I just pasted the Arduino code into GROK and asked it for Picomite version. It paused about a second and then offered me it’s version in MMB. I wasn’t suprised that it didn’t work of course but actually most of the code was readable and there were some obvious lines where it had used a syntax from older Basics. It actually saved me a fair bit of typing and provided a ‘leg-up’ to the problem that I could de-bug rather than starting from (head) scratch(ing).

      I was therefore very interested to see this post from Peter M on the BS Forum this morning about his use of  the CLAUDE AI to convert some 3D images. Peter “trained” it by feeding in the PicoMite manual and then gave it an example to examine. CLAUDE failed the first time around but after Peters feedback was able to diagnose why.

      Here is Peter’s post – 3D Elite ‘Viper’ code from CLAUD

      You don’t need to be interested in 3D graphic versions of Elite on the Picomite – just look at the response from the AI to the problem, which Peter has quoted. It really is quite remarkable (at least to me). I’m sure others might find this old news but these things do seem to be moving along extremely quickly.

      Putting the concerns about AI to one side, it seems there is a new tech on the block that can save you time (an increaingly valuable thing to me) if you take the time to learn how to use it correctly. A lot like 3D CAD, CNC, 3DP in fact. So just when I thought I had already used up my last gray cells, I’ll hsve to find some more ….  🙂

      Regards,

       

      IanT

      #818055
      SillyOldDuffer
      Moderator
        @sillyoldduffer

        I prefer “Machine Learning” to “Artificial Intelligence”, because most people are misled by AI as described in science-fiction, which is not real.   HAL attempts to murder Dave in “2001 A Space Odyssey”, and Captain Kirk and Doctor Who both fell foul of demented computer systems!  And science-fiction isn’t an ideal predictor: robots exist in large numbers today, but they aren’t like people.

        Computer science has made a major leap forward.  Several ways and means have come together by which machines can assimilate large volumes of data, extract information from it, and then apply it as knowledge.  They also learning from experience and able to infer and deduce.   The advances depends partly on hardware: Moore’s Law plus efficiencies like vector and arithmetic accelerators.  And partly on software: advances in pattern recognition, game theory, algorithms, analytical methods, and efficient methods.  This is just the beginning.

        Ironically, Machine Learning is really good at is computer programming.  Computer programmers invented it and they are first for the chop!   It shines at programming because it’s a logical rules based discipline. As is most  engineering.   Human opinions, values, emotions, beliefs, lies, wishful thinking, mistakes, ignorance, laziness, and prejudices don’t muddy the water.

        Refactoring code is something an AI should do well – up to a point!  But, there are plenty of things in C/C++ that aren’t supported at all by MMB.   Might be more useful for chaps primed on BASIC to learn C/C++ by using Claude to go the other way – convert BASIC into Arduino…

        🙂

        I agree AI is well worth getting to know.  May not require any effort at all – it’s appearing in all the search engines, and rather effectively too.   Have to say much more trustworthy with hard facts than anything depending on opinion, and it does tend to learn human rubbish.  The internet isn’t entirely reliable!

        Dave

        #818150
        IanT
        Participant
          @iant

          Peter has just put this demo up if anyone if interested in the code generated by CLAUDE…

          Elite Cobra – MMB 3D rendering 

          I’m not interested in ‘Retro’ gaming myself but might be tempted to get some help setting up the twelve ‘State Machines’ (the RP2350 has three PIOs) inside the Pico 2 for extremely fast I/O.  The PicoMite already supports a built-in PIO ‘assembler’ for these SMs but it would be very nice if I could get some automated assistance.

          Regards,

           

          IanT

           

          #818156
          Robert Atkinson 2
          Participant
            @robertatkinson2

            If the results of Google’s AI results are anything to go by don’t bother. It makes up complete nonsense including aircraft accidents that never happened and verbose “descriptions” with no more information than what was entered.
            For software and the like be very wary of IP issues. For free systems they almost certainly retain rights over code produced and often over source data entered. Note you may be breaching other peoples IP by entering thair code, specifications or other data into an AI system.

            Robert.

            #818158
            IanT
            Participant
              @iant

              Well, thought I’d have a quick go – but with GROK (as I’ve used it before).

              The application is that I would like to use a large colour VGA monitor (because I cannot read LCDs in poor light) to read two iGaging scales and add some other useful (custom) functions in the process.

              Here is the output after a couple of prompts from me…

              GROK output -12.40 011025

              Overview

               

              The iGaging DRO (Digital Readout) scales use a simple synchronous serial protocol over two lines: a clock line (output from the host) and a data line (input from the scale). The host generates 21 clock pulses, and the scale outputs one data bit per pulse. The data is a 21-bit two’s complement signed integer representing the position, transmitted LSB-first.

              Key protocol details:

              Pinout: Clock on one pin (e.g., GPIO 0), Data on another (e.g., GPIO 1). Power the scale with 3.3V and GND (via USB Mini/Micro-B or direct wiring: VDD=3.3V, SSY=Clock, DATA=Data, Frame=GND).
              Timing: Clock frequency ~5-20 kHz (e.g., 10 kHz, period ~100 µs). Data is sampled on the falling edge of the clock (clock high-to-low transition). Data changes shortly after the falling edge and remains stable during the low period. Use ~50% duty cycle for the clock pulses.

              Bit Order: LSB first (first bit clocked out is the least significant bit).
              Data Format: 21-bit two’s complement integer. LSB = 1/2560 inch (≈0.01 mm or 0.00039″). To convert to inches: position / 2560.0. For mm: position / 100.806. Sign-extend for negative values (e.g., left of zero).
              Refresh Rate: Up to 50 Hz; poll as needed.

               

              This is ideal for RP2350 PIO: one state machine generates the clock pulses and shifts in the bits autonomously. The data is pushed to the TX FIFO for the CPU to read.
              PIO Program (save as igaging.pio)
              text.program igaging_read

               

              .side_set 1

              ; Load counter (21 bits)
              mov x, 21

              ; Main loop: Generate clock pulse and sample data on falling edge
              .loop
              set pins, 1 side 1 [3] ; Set clock HIGH, delay 3 PIO cycles (setup/hold high)
              set pins, 0 side 0 ; Set clock LOW (falling edge)
              nop [1] ; 1-cycle settle time for data after falling edge
              in pins, 1 ; Shift in 1 bit from data pin (LSB first, right-shift)
              jmp x– .loop ; Decrement counter; loop if != 0 (runs 21 times)

              ; ISR now holds 21 bits (padded to 32); auto-push to TX FIFO

               

              Timing Notes: Assumes PIO clock = 100 kHz (set via clkdiv in C code), yielding ~10 cycles/bit (~100 µs period at 10 kHz clock). High time: ~40 µs (4 cycles), low time: ~60 µs (6 cycles, including instructions). Adjust [3] and [1] or clkdiv based on oscilloscope testing for your scale (aim for clean data edges). PIO instructions take 1 cycle each; delays are calibrated for 50% duty approx.
              Shift Config: Shifts right into ISR (LSB to bit 0), auto-push after ≥21 bits.

              Most of this information I’d already managed to dig out for myself but it did take me a while. GROK did this in a few minutes… I’m really going to have to use this tech a lot more in future…

              Regards,

               

              IanT

              #818188
              Robert Atkinson 2
              Participant
                @robertatkinson2

                But is description correct? Does the code actually work?

                #818207
                SillyOldDuffer
                Moderator
                  @sillyoldduffer

                  Dunno if the AI code works, but this example written by me in Micropython does.  It’s a minimum “hello world”, that outputs a 10uS square wave on GPIO Pin 16.

                  pioexample

                  As a test of the AI, see if it can convert my MicroPython into MMB.

                  The Python to BASIC conversion is straightforward because the example program is simple, and basic Python and basic BASIC are very similar.

                  The state machine assembler inside pulse() is a more challenging conversion because the syntax is somewhat different.  For example Micropython has me typing “set(pins, 1)[3]” rather than “set pins, 1 side 1 [3]”.    Just an implementation difference, though.  The syntax suggested by AI is like that bundled with the Picos original C compiler, and MMB’s developer may have stuck with that, whilst Micropython have done some simplifying.    Nothing wrong with either,  other than they’re slightly different.  Stops us getting bored!

                  Dave

                   

                  #818291
                  IanT
                  Participant
                    @iant

                    As far as I can see Robert, the information is correct – within the context of the question asked. I didn’t make any reference to MMB at all for instance – just wanting the PIO part of the solution.

                    I didn’t keep a transcript of the ‘dialogue’ with GROK, which was a mistake and something I will do in future. However, I did watch as it opened and read the RP2350 product reference and the SDK reference – so it ‘briefed’ itself on the subject matter and did so in a few seconds.

                    I think part of learning to use these systems effectively is to take the “Genie” approach. When making your ‘Wishes’ think carefully about what you need/want – and be careful how you ask for it.  🙂

                    I haven’t tried the code as yet (I have a new mill that is geting some mods and relatives coming to stay and Management wants the bathroom decorated) but I will do so when I get some time.

                    Regards,

                     

                    IanT

                    PS Peter (who is the developer of the PicoMite version of MMB and certainly not a dummy like myself) posted this comment yesterday about how he migrated that 3D Elite image posted above.

                    ” This has been a genuinely interesting day. There is precisely NO WAY I could have solved this by myself – pretty humbling.

                    To make it work a modification to the MMBasic firmware has been needed to add a new feature. Rendering of the 3D object works by Painters algorithm. This works by sorting the faces and drawing those further away first. In addition the MMBasic firmware supports “back face culling”. This doesn’t draw faces that are pointing away from the camera. In order to sort the faces the current MMbasic code uses the Z axis position of the face centroid. This works in many situations but in some 3D models it is better to use the furthest vertex and sort on that. I’ve added that as an option to DRAW3D SHOW and DRAW3D WRITE “

                    #818336
                    SillyOldDuffer
                    Moderator
                      @sillyoldduffer

                      OK, grok responded to my micropython example above with this conversion to MMB:

                      SETPIN GP16, PIO0
                      PIO ASSEMBLE 0, “.program pulser”
                      PIO ASSEMBLE 0, “.line 0”
                      PIO ASSEMBLE 0, “set pindirs, 1”
                      PIO ASSEMBLE 0, “jmp loop”
                      PIO ASSEMBLE 0, “.line 2”
                      PIO ASSEMBLE 0, “wrap_target”
                      PIO ASSEMBLE 0, “loop:”
                      PIO ASSEMBLE 0, “set pins, 1 [9]”
                      PIO ASSEMBLE 0, “set pins, 0 [9]”
                      PIO ASSEMBLE 0, “wrap”
                      PIO ASSEMBLE 0, “.end program”
                      p = Pio(pinctrl 0,1,,,,GP16,)
                      e = Pio(execctrl 31, 2, 4)
                      PIO INIT MACHINE 0, 0, 1000000, p, e
                      PIO START 0, 0
                      PRINT “Starting. Out is GP16”

                      Looks correct to me!  Though the syntax differs, the logic is identical.  Could Ian try it please?

                      Grok took 2 minutes 32 seconds to do the conversion, and listed a number of steps that a human might follow, starting with “read the MMB Manual”.  The AI summary is sensible.   Of interest is that Grok coped with two versions of the PIO assembler, so it’s translating three languages not just two.

                      A quirk! I, writing code for a human said:

                      set(pins,1)[10-1], which grok converted to PIO ASSEMBLE 0, “set pins, 1 [9]”.  They are equivalent.

                      But I said [10-1] because I want the reader to focus on the wanted delay which is 10uS.  The wait is 9 cycles but set(pins) takes 1 clock cycle, so the total is 10.   9 obfuscates that this is a 10uS delay.  Grok didn’t understand why I wrote 10-1 rather than 9, and simplified it.  In the same vein, my code has many explanatory comments, which grok doesn’t bother with.  It might if I ask it to!

                      To reinforce Ian’s point, grok did the conversion far faster that I could! Even though I’m familiar with both MS-BASIC and Python and have a nodding acquaintance with PIO assembler.

                      Dave

                       

                       

                      #818355
                      IanT
                      Participant
                        @iant

                        Thanks Dave – I was trying to bone up on the MMB PIO assembler over coffee this morning. A BSF member wrote a very useful tutorial on PIO usage (in addition to the chapter in the PicoMite V6 manual).

                        I originally built a simple PicoMite setup to test my theory that the scales were the 21 bit iGaging ones (they were purchased from a UK source but not ‘branded’ as such) which I connected to a scale to generate the required clock signals & GND/Volts. I was able to see the incoming data on my ancient Tectronix scope and confirm the format. Given that I will need to read at least two axis, I realised that the PIO facility would have to be used but didn’t have the time to go further…

                        At the moment I plan on using a VGA monitor (I’ve got a simple DRO ‘display’ written) but it’s occured to me that a 10″ HDMI PicoMite (I’ve already built two for the kids) might be a better option or I could even use a Waveshare 2.5″ Touch screen.  I have one installed on my Quad Dev system (saves carting a large screen around). All of these have bright/colour screens which would be a big improvement on the grey, unlit LCD readout.

                        I’ve been playing with my new Seig mill.  I have exactly the same problem with the grey Z-axis ‘scale’ on the front – I can’t read it without using a torch….

                        Regards,

                         

                        IanT

                        #822299
                        amdjok
                        Participant
                          @amdjok

                          I am a very old man (65) who started in High School on a Digital Equipment Corporation, PDP1145.

                           

                           

                          192.168.1.1 192.168.100.1

                          #822300
                          JasonB
                          Moderator
                            @jasonb
                            On IanT Said:

                             

                            I’ve been playing with my new Seig mill.  I have exactly the same problem with the grey Z-axis ‘scale’ on the front – I can’t read it without using a torch….

                            Regards,

                             

                            IanT

                            Try a new battery, they can become dim as the battery gets old.

                            #822304
                            IanT
                            Participant
                              @iant

                              I think it’s mostly having the wndow behind the mill and where the overhead lights are situated Jason but I’ll try it.

                              We’ve got relatives from Canada arriving shortly, so my priorities are being dictated by HWMBO and my inability to put in a full days work decorating. Anyway, I’m being discouraged from bunking off to the shed at the moment… 🙁

                               

                              IanT

                            Viewing 13 posts - 1 through 13 (of 13 total)
                            • Please log in to reply to this topic. Registering is free and easy using the links on the menu at the top of this page.

                            Latest Replies

                            Home Forums The Tea Room Topics

                            Viewing 25 topics - 1 through 25 (of 25 total)
                            Viewing 25 topics - 1 through 25 (of 25 total)

                            View full reply list.