Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : TinyBasic for the ATTiny85
Page 2 of 4 | |||||
Author | Message | ||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6100 |
Coming not quite as soon, MMEdit for ATTiny Automatic line numbering. One button, instantly switch from 'normal' readable code to the crunched version required to fit the tiny, and back again. It will be a couple of weeks before I have the ATTiny85 to test with but I should have it released well before then. Weather and life matters permitting. Jim VK7JH MMedit MMBasic Help |
||||
Sasquatch Guru Joined: 08/05/2020 Location: United StatesPosts: 362 |
Looks great Jim, I'm sure you caught the note about the "speed limit" when sending code to the ATTiny85 due to the echo of each character blocking the next incoming character. Also a byte count would be very helpful, especially in "crunched" mode. I'd offer to send you an ATTiny85 chip, but I see you are in Australia and I have found the postal service to be extremely slow to that part of the world. Please let me know IF I can be of any help with testing etc. -Carl |
||||
Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1114 |
MMBASIC 208 Bytes M=64:FOR J=-20 TO 20:FOR I=-40 TO 40 V=J*4:U=I*3-40:X=U:Y=V:N=0 3 R=X*X/M:Q=Y*Y/M:IF R+Q>256 THEN 6 IF N>=64 THEN ?" ";:GOTO 7 Y=2*X*Y/M+V:X=R-Q+U:N=N+1:GOTO 3 6 ?CHR$(64-28*(n MOD 2)); 7 NEXT:?:NEXT Edited 2023-07-27 16:14 by Martin H. 'no comment |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6798 |
@ matherp Would 1-Wire be feasible on this? It would kinda fit the physical size of the chip. :) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
Sasquatch Guru Joined: 08/05/2020 Location: United StatesPosts: 362 |
Nice work @MartinH! Since all of the 'Mites support some form of floating point arithmetic, we can get rid of the multiplier 'M' and change some of the constants saving about 10 bytes. Next we can simplify the Print statement and add more contrast at the same time saving a couple more bytes. What we now have is possibly the world's smallest Mandelbrot program??? Note that these new programs will NOT run on the Tiny85 Basic but run fine on PicoMite and PicoMiteVGA (Mode1) and will likely work on any of the other 'Mites with 80X40 text display or suitable terminal program. Now that we have thoroughly hijacked the Tiny85 Basic thread with all things Mandelbrot, lets re-focus the thread on Peter's new Basic interpreter for the ATTiny85 For J=-20 To 20:For I=-40 To 39 V=J/15:U=I/25-.7:X=U:Y=V:N=0 3 R=X*X:Q=Y*Y:If R+Q>4 Then 6 If N>=64 Then Print " ";:GoTo 7 Y=2*X*Y+V:X=R-Q+U:N=N+1:GoTo 3 6 Print Chr$(33+N Mod 7); 7 Next :Print :Next Edited 2023-07-28 00:42 by Sasquatch -Carl |
||||
Sasquatch Guru Joined: 08/05/2020 Location: United StatesPosts: 362 |
So, In keeping with the theme of the OP for this thread, I've been thinking about possible applications for the ATTiny85 Basic. There are hundreds if not thousands of small circuits based on the 555 timer IC and/or a handful of logic gates and as @Mixtel90 pointed out in the other thread, these Tiny85 Basic chips are potentially far more versatile. Here are just a few applications that I thought of, there are likely hundreds more: HI/LOW Voltage alarm/relay control (think Solar or other battery applications) HI/LOW Temperature alarm/control De-bounce for all types of switches or sensors Delay ON timer Delay OFF timer Servo/PWM controller Analog to PWM converter RGB LED controller Low frequency clock generator Low frequency clock divider/PLL Sensor to serial/USB interface Serial/USB to relay or PWM interface What applications have you thought of??? Edited 2023-07-28 01:05 by Sasquatch -Carl |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4246 |
I used picaxe 08M for many of my RC projects. Key is that you can measure pulse width. Typical you need to measure 1-2 ms. With 16 bit signed integers that would be 1us...10us per lsb to be usable in tinybasic. Sure Peter can do this. But I have lost interest in RC, so most likely will not use it. But it may be of interest for others. Volhout PicomiteVGA PETSCII ROBOTS |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 9126 |
Here is the latest (final?) version of the firmware. Simplified the source and sone performance improvement. ATTiny85.zip New commands VARS 'list the values of all variables (code from Volhout) HELP 'list all valid commands, functions, and operators (code from Volhout) WITWOC addr, data e.g. WI.104,0 'write to DS1321 RTC to point to the seconds register New Function RITWOC(addr) e.g A=RI.(104) 'read the register on the DS3231 previously set up New Operator % e.g. B=A%16 'B = A MOD 16 Source ATTiny85.zip Edited 2023-07-28 02:41 by matherp |
||||
Sasquatch Guru Joined: 08/05/2020 Location: United StatesPosts: 362 |
Here are a few additional thoughts about Tiny85 Basic for @matherp and the group to consider. Keep in mind these are only suggestions based on my current thinking and may not be practical or even possible. I'm just trying to anticipate simple ways to make the device more useful: The LET command is completely useless, and we don't need backward compatibility as this is a new project. We don't need REM as we can use ' if we actually have room for comments PEEK/POKE should possibly only work for the address range of the hardware registers? Perhaps the range of addresses could be shifted such that PEEK(0) would access the start of the hardware register address space? STOP seems redundant? How is it different then END? Do we really need ECHAIN? This implies that you have stored a program in EEPROM memory, which will run on reset by default, and then load another program by serial terminal that will then ECHAIN to the program in EEPROM? Seems like a very limited use case. Perhaps AWRITE could be expanded to allow a (potentially optional) parameter to set the frequency? Or perhaps AFREQ command to set the frequency? Or maybe add a PWM command as a slight variation of AWRITE? Otherwise we could use AWRITE to set up the hardware and then POKE the hardware registers to change the frequency? Some kind of PULSEIN command would likely prove useful as @Volhout suggests, but this may be a stretch given the limited resources. Please chime in if you have other suggestions based on your experience! -Carl |
||||
Sasquatch Guru Joined: 08/05/2020 Location: United StatesPosts: 362 |
LOL you posted this as I was editing my post. Will do some testing on the new version! And maybe some examples to get people thinking about the possible applications. Edited 2023-07-28 02:44 by Sasquatch -Carl |
||||
Sasquatch Guru Joined: 08/05/2020 Location: United StatesPosts: 362 |
More thoughts on ECHAIN: IF we could store a second program in EEPROM, i.e. ESAVE 2, then ECHAIN 2 makes a lot of sense! -Carl |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4246 |
Peter, How did you achieve a low RAM usage by the interpreter. On my arduino build, the system uses 1300 bytes of RAM. I must admit that arduino defaults to have 128 bytes (2 x 64) UART buffer, but that does still far exceed the RAM usage in your build (512-280=232 bytes). I wonder if I can make the arduino build similar effective. It would increase the RAM available for program from 700-800 bytes to over 1.5k.... significant. Thanks in advance for your answer, Volhout PicomiteVGA PETSCII ROBOTS |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6100 |
MMEdit is progresing well. Go from this: to this: and back again. You can edit in either mode. I need a few more sample programs to test with. Preferably ones that can be copied and pasted, not retyped. A question. Is there a preferred line ending? CRLF or LF alone and do the line endings count as characters? I will be happier once I have the chips and programmer in a weeks or two. Plenty of real life issues to keep me busy until then. Jim VK7JH MMedit MMBasic Help |
||||
disco4now Guru Joined: 18/12/2014 Location: AustraliaPosts: 897 |
My first go with TinyBasic on the ATTINY85. The code uses the new MOD operator and the I2C READ and WRITE to drive a PCF8575A 8-bit I/O expander with the ATTINY85. The PCF8574A is wired up with pins P0-P3 as inputs. (10K pullup and switch to ground to activate). Pins p4-p7 are wired to LEDs via a suitable resistor to ground. Pressing a switch or multiple switches will light the corresponding LED(s) as a demonstration of input and output on the PCF8574A 'TEST OF I2C on ATTINY85 TinyBasic 'PCF8574A P0-P3 with 10k Pullups and switch to GND ' P4-p7 with LED to GND via resistor. 'Pressing switches 0-3 will light the corresponding LEDs 'ATTINY85 SDA pin2 i.e PB3 'ATTINY85 SCL Pin3 i.e PB4 'addr =&H38 i.e. 56 'read pins &H0f i.e 15 10 B=15 20 A=RI.(56) 30 IfA%2>=1GO.50 33 B=B+16 50 IfA%4>=2GO.60 53 B=B+32 60 IfA%8>=4GO.70 63 B=B+64 70 IfA%16>=8GO.80 73 B=B+128 80 WI.56,B 81 B=15 82 GO.20 Latest F4 Latest H7 |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 9126 |
Excellent. I hoped the I2C would be useful for thinks like a port expander |
||||
disco4now Guru Joined: 18/12/2014 Location: AustraliaPosts: 897 |
For those that don't like using the command line, I have successfully used this GUI front end for AVRDUDE. It sets all the fuses so just read them in before you set/change the ones you want to actually change. I did a portable install into a directory and placed the ATTiny85.hex in there as well. AVRDUDE GUI interface Latest F4 Latest H7 |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6798 |
I don't know why, but the PCF8575A is remarkably difficult to find here in the UK. There's apparently no through-hole version at all, but there's one source (on Amazon) of the SMD version on a breakout board. The MCP23008 is no problem at all. Just one of those things, I suppose. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
CircuitGizmos Guru Joined: 08/09/2011 Location: United StatesPosts: 1425 |
Is this right? Edited 2023-08-01 11:59 by CircuitGizmos Micromites and Maximites! - Beginning Maximite |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9308 |
Oh, hey! Great to see you back on the forums, CG! I thought we had lost you. Smoke makes things work. When the smoke gets out, it stops! |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6798 |
I think that's right, CG. For now anyway. By next week? Nice to see you again. :) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
Page 2 of 4 |
Print this page |