Serial (RS232) 4x16 servial display

General discussion on mikroBasic PRO for PIC.
Post Reply
Author
Message
Quark
Posts: 3
Joined: 27 Jun 2018 06:32

Serial (RS232) 4x16 servial display

#1 Post by Quark » 27 Jun 2018 07:04

I am using a PIC 18F25K42 in a data logging + monitoring project.

The project is well developed in PROTON BASIC but would like to port to MikroBasic.

I must say every compiler I have purchased over the last 40 some odd years has been well documented - which is not the case for MikroBasic.

In Proton Basic ( and in most other PIC basics ) there are modifiers to display data on a terminal or serial (RS232) display.

I can transmit data easily enough using UART1_Write() and Text using UART1_Write_Text() -- but I have not found a way to format the data for display.
In this case I would like to display the 12 BIT high and low registers containing the result of an ADC conversion - ADRESL ADRESH - both as Binary and Decimal.
In Proton Basic one need only add DEC or BIN in front of the data to be displayed. Also the number of display places may be indicated by indicating the number of place such as BIN3 or DEC4. I'm sure there is an easy way to do this in MikroBasic but I can't find an example.

This is a very important project so stability is key.

Thank you very much!

Quark

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Serial (RS232) 4x16 servial display

#2 Post by filip » 27 Jun 2018 14:50

Hi,

There is no built-in function that converts decimal to binary (actually, there are Dec2Bcd and Dec2Bcd16 functions in the Conversion library, but I'm not sure if this is what you want).

Anyway, you can use this simple code for conversion of 16-bit word type to binary (result is placed inside an array) :

Code: Select all

program test

dim binary as byte[17]

sub procedure BIN(dim value as word)
  dim i as byte

  i = 16
  while(value > 0)
    if ((value mod 2) = 0) then
      binary[i] = 0
    else 
      binary[i] = 1
    end if
    Dec(i)
    value = value div 2
  wend
  binary[0] = 0
end sub

main:
   BIN(43690)
end.
Regards,
Filip.

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: Serial (RS232) 4x16 servial display

#3 Post by janni » 27 Jun 2018 16:01

Quark wrote:I am using a PIC 18F25K42 in a data logging + monitoring project.

The project is well developed in PROTON BASIC but would like to port to MikroBasic.
Filip probably has not noticed which processor you use and thus hasn't mentioned that mB is not ready for K42 processors. After reading this topic you'll probably want to wait for the promised upgrade before porting your project.

Quark
Posts: 3
Joined: 27 Jun 2018 06:32

Re: Serial (RS232) 4x16 servial display

#4 Post by Quark » 27 Jun 2018 21:11

Thank you very much for the help! I am simply wanting to display the 12Bit ADC value from the 18F25K42 on a Serial RS-232 display.

I purchased MikroBasic pro only because sales told me that will compile code for the 18F25K42. The Proton Basic compiler works great on earlier 18F MPUs but has a bug in reading the ADRESH register causing only 11 of the 12 Bits to display. In other words it truncates the 12th Bit. I am a little shocked to also find out there are no builtin commands to simply address a serial(RS232) non-graphic display. I understand that Mikro Electronics is focused on new produces - but is there anyone working on existing products like MikroBasic? I only ask this because see many customers upset on the blog.

I'm very limited with code space for my application - and strings may eat up too much space.

Thank you. But I guess I should ask for a refund. Do I need a ticket from support to ask sales for a refund?

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Serial (RS232) 4x16 servial display

#5 Post by filip » 28 Jun 2018 10:17

Hi,
I am a little shocked to also find out there are no builtin commands to simply address a serial(RS232) non-graphic display. I understand that Mikro Electronics is focused on new produces - but is there anyone working on existing products like MikroBasic?
We are working on every compiler, so the mikroBasic is not an exception here.

The functionality that you require for your project is simply not implemented in the compiler.
On the other hand, some libraries the exist in the mikroBasic are not present in another development environment.

Therefore, user switching from one to another may find the lack of the available features "shocking",
but in fact the desired features can be easily implemented - for this purpose there is a free demo version of the compiler which can be used for evaluation.

You can open a ticket at our HelpDesk, so we can continue the correspondence there.

Regards,
Filip.

ilferrari
Posts: 195
Joined: 18 Nov 2013 09:09

Re: Serial (RS232) 4x16 servial display

#6 Post by ilferrari » 28 Jun 2018 20:39

As a longtime user of Mikrobasic, I don't agree that it is poorly documented. The help file covers pretty much everything. The conversions library has a function WordToStr to convert a int16 to a decimal string. If you want to convert the ADC register to a binary string (I don't see why), as an experienced programmer you should be able to create a routine for that in your sleep, assuming you know how to test a bit and what ascii values '0' and '1' are.

Quark
Posts: 3
Joined: 27 Jun 2018 06:32

Re: Serial (RS232) 4x16 serial display

#7 Post by Quark » 28 Jun 2018 23:56

Thank you very much Filip.

I understand the way your library system works - I only wish there were more of the most common library functions available.

And thank you so much ilferrari, but I can only agree to disagree. I wrote my first basic compiler for the RCA 1802 in the late 1970s and I remember clearly that I spent more time on the documentation and examples than I did writing the compiler.
It is a tough job to do it right but invaluable to the user.
I understand in business it all comes down to ROI. I only wish the many errors in the examples could be cleaned up and important documentation be added.

I was able to look at the generated mnemonics to understand how the compiler operates - but honestly the reason I - and most people use basic is to save time.
I could certainly code the application in "C" or assembler or machine language - but that takes time. And looking for documentation also takes a good deal of time.

The working idea when we invented BASIC was to make coding easy - foolproof and quick.

And certainly given time I could easily write all the libraries needed, but leaving a serial IO formatting library out of Basic is like leaving stdio.h out of "C".

The Mbasic compiler is a reasonably priced - and for someone who needs an inexpensive compiler and has lots of time to spend it is a good product.

At my age I only wish I could recover the years of my life I spent doing such things :)

I would suggest you remove the PIC18F25K42 - maybe the entire k42 family from supported MPUs until the bugs are ironed out.
No need to waste the valuable time of others.

By the way - many PIC18F25K42 MPUs have several problems in the silicon. The most interesting is a problem occurs when selecting the ADC FRC Clock. This can result in a missing 12th bit and other random problems. The workaround is to use the /128 internal clock.

Since I come from a world where we wrote code one bit at a time - I often like to look at the "binary" contents of an SFR or memory location. My mind as many older programmers works in 1s and 0s :)

Post Reply

Return to “mikroBasic PRO for PIC General”