PDA

View Full Version : Multi-digit word variable to string



Amoque
- 25th March 2012, 18:28
Good morning.

I have recently resurrected an old project as a means of introducing myself to PBP3 and the PIC16F88. It is a scrolling marquee on a single 5x7 matrix LED; the characters are 5x5 and with some missteps, I am now able to display a static message quite satisfactorily. Yaye me!

To extend my knowledge, I determined to interface an LM34 temperature sensor as demonstrated here: http://www.rentron.com/PicBasic/LM34.htm. The project calls for a PIC16F677--the ADC setup is different, but therein lays the learning. Armed with the datasheet, I went to work… a reasonable period later, I felt I had adequate understanding to program some code.

While I may (or may not) have gotten the ADC configured properly, the real frustration is displaying the result! I had intended to use the [DEC] statement, [DIG], and some division to insert each digit into the string array for display, but [DEC RawT (the word variable holding the ADC result)] results in a “Bad expression” error. I had thought perhaps that my ADC result was indecipherable, but even setting RawT to a likely value does not change the result.

TL;DR:
Can someone with a better understanding demonstrate how a multi-digit word variable be converted to a single digit string format; i.e. RawT=754 --> MSG[x]= “7”, MSG[x+1]= “5”, MSG[x+2]= “4”? Also, seeing that I’ve impinged on your good nature already, can you verify my ADC configuration to read from AN0 on pin17, using a +Vref on AN3 (pin 2)?

Many thanks...

CONFIG:
#CONFIG
__config _CONFIG1, _INTRC_IO & _WDT_OFF & _PWRTE_OFF & _MCLR_ON & _BODEN_OFF & _LVP_OFF & _CPD_OFF & _WRT_PROTECT_OFF & _DEBUG_OFF
__config _CONFIG2, _FCMEN_OFF & _IESO_OFF
#ENDCONFIG
DEFINE OSC 8
OSCCON = %01110000
ANSEL = %00001001 'ANALOG OFF, EXCEPT +Vref AND AN3
TRISA = %0001001 'PORTS TO MATCH ANSEL
ADCON1.7 = 0 : ADCON1.6 = 0 : ADCON1.5 = 1 : ADCON1.4 = 0 'LEFT JUSTIFIED : ADCS2 DISABLED : VCFG Vref+ AVSS
ADCON0 = %01011001 'Fosc/8 : AN3 ACTIVE : ADON (BIT0) ADC ON
TRISB=0 'PORTB DIGITAL

HenrikOlsson
- 25th March 2012, 18:57
Hi,
One way could be to use the ArrayWrite command, something like:


MSG VAR BYTE[4]
RawT VAR BYTE

RawT = 754

ARRAYWRITE MSG, [DEC RawT]

/Henrik.

Amoque
- 25th March 2012, 19:29
Thank you, Henrik.
I love when the answer is shorter than the question!

To be clear then, it appears that DEC is not a command of itself, but a parameter of some other display functions; it is only valid in an output string to an LCD or other output device (ie serial port) or construct (array-obviously).

I hope it is not too much trouble for any who follow this thread to correct my interpretation as well as to clarify one more point? Can an entry point be specified, as ARRAYWRITE MSG[14], [DEC RawT] so that the variable may be positioned in a larger array? I saw little on this when searching

It is possible to specify an entrypoint, so that (for example) the string "Temperature = XXX degrees" can be dynamically updated with Arraywrite ARRAYNAME[entrypoint] = [DEC variable]

HenrikOlsson
- 25th March 2012, 20:06
Hi,
That's correct. DEC is not a command by itself, it's what the manual calls a modifier among others (BIN, HEX etc).

I've never tried it but I'm pretty sure you can start anywhere in the array in the way you show.

/Henrik.

astanapane
- 28th September 2020, 08:32
Hello all,

this is an old post. I'm not sure if my question fits right to here.

I have a temperature values and i would like to send them to a display from 4D Systems.

At the moment i was using the serial SPE commands as 4D Systems calls it, and they have exactly the command to send those variables.

Then i tried their "new" Visi Genie enviroment, which allows you to create "forms" and add any image, button etc.

I have fniished the easy task inside the Visi Genie and i'm in front of a problem that i need to transform the variable to string.

As from 4D Systems:


Visie-Genie writes to pre-defined objects so in this case it is a pre-defined string object so all we have to do is convert what we need to send to a string, calculate a checksum and send. This is where Genie differs from Serial as in the Serial mode you are sending a serial command to the display which is translated to a command to do a supported function on the display.

It is the first time i had to do a task with Checksum and found it interesting way by XORing all the bytes. In a very small code i tryied it worked, as i sent based on 4D Systems the command to change the constrast and it worked.




command var byte
constrast var byte
CS var byte

' -----------------------------------------------------------------------------|
' [ LCD Initialization ] |
'------------------------------------------------------------------------------|
' FIRST TIME BOOTUP: We give plenty of time for tbe LCD '
lcdinit:
pause 2000
command = $04
contrast = $06
gosub checksum
hserout [command,contrast,CS]
hserin [wait(6)]
pause 100


high green
return

'------------------------------------------------------------------------------|
' CHECKSUM |
'------------------------------------------------------------------------------|
checksum:
cs = 0
cs = cs ^command
cs = cs ^ contrast
return

Now i'm trying to see the way to convert var to string. I have read the manual written in 2013


"A numeric value preceded by a pound sign ( # ) will send the ASCII representation of its decimal value, up to 65535. For example, if W0 = 123, then #W0 (or #123) will send "1", "2", "3"."

Is that the right way? May i have your help please?

Ioannis
- 28th September 2020, 09:50
Or use DEC modifier like DEC k. If k=5, DEC k will send out the "5".

With DEC you can also specify how many digits you will send. E.g. DEC3 will send 3 digit of the variable with the appropriate leading zeros in this case to fit the number of digits requested.

If k=15 then DEC3 k will send "0", "1", "5"

Ioannis

astanapane
- 28th September 2020, 10:54
Thanks so much Ioanni,

will try it out.

astanapane
- 18th December 2021, 19:05
Dear all,

i have some problem regarding the conversion of a variable to string.

I have the following code.




'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''
' VAR for IR to LCD '
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''
IRCS var byte ' this is the checksum for the IR required in external display command
TEMP var word ' this is the word variable for TEMP
temperature var word ' for result and output to lcd
TEMPIR var word ' set a variable tempir
Remainder var word ' Get the remainder = tempir//50

'------------------------------------------------------------------------------*
' Measure IR object temp sent to uLCD *
'------------------------------------------------------------------------------*
object:

reg = $07 ' based on the datasheet $07 is the object's temp
addr = %10110100 ' $B4 binary value: %10110100
i2cwrite SDA, scl, addr ' send write command, shift the address B4, 8 bits where LSB is W = 0
i2cwrite sda, scl, reg ' register is $07

addr = %10110101 ' $B5 Binary value: %10110101
i2cwrite sda, scl, addr ' sends read command, shift the address B5, 8 bits where LSB is R = 1, clock idles low
i2cread SDA, SCL,addr,reg,[temp.lowbyte,temp.highbyte] ' reg = $07


tempir = (temp.highbyte << 8) + temp.lowbyte

temperature = tempir/50 ' based on the manual we need to divide by 50 or 0.02
temperature = temperature - 273 ' subtract 273 for Degree in C,actually is 273,15
remainder = (tempir*2)//100 ' multiply x 2 and get the remainder //100

pause 100
gosub display
return

'------------------------------------------------------------------------------*
' IR Display 1 the parameters *
'------------------------------------------------------------------------------*
display: ' IR TEMP
hserout2 [$73,$00,$02,$12,$00,$ff,"IR TEMP:",00]
Hserin2 timeout,error,[wait(6)]
hserout2 [$73,$08,$02,$12,$F8,$00,dec2 temperature,".",dec2 remainder,"*C",00] 'this one works on display 1 which doesnt require CS
Hserin2 timeout,error,[wait(6)]


gosub checksum2
hserout [$01,$0F,$00,temperature,remainder,IRCS] ' this one doent work, i get random numbers on the display.
Hserin timeout,error,[wait(6)]
return

'------------------------------------------------------------------------------|
' CHECKSUM IR |
'------------------------------------------------------------------------------|
checksum2:
IRCS = 0
IRCS = $01 ^ $0F ^ $00 ^ temperature
IRCS = IRCS ^ remainder
return




One i do the CS calculation, and returning from checksum2 the following is not working as expectred.


hserout [$01,$0F,$00,temperature,remainder,IRCS] ' this one doent work, i get random numbers on the display.
Hserin timeout,error,[wait(6)]
return


even if i try the following.


hserout [$01,$0F,$00,dec2 temperature,dec remainder,IRCS] ' this one doent work, i get random numbers on the display.
Hserin timeout,error,[wait(6)]
return


Is there a way to convert the variable to string ourside from a preset command like the HSEROUT?

for example is there a way to make something like this in PBP?

temperature = #temperature.

Ioannis
- 18th December 2021, 20:17
If your variable is ranging from 0 to 65536 (the maximum that word can hold) obviously the HSEROUT command cannot handle that. With HSEROUT you can use only ascii values.

So, as you have already find out, the dec2 temperature does work. Maybe your value is beyond 2 decimals so you have to use dec5 to be sure and cover all temperature values?

Ioannis

astanapane
- 18th December 2021, 20:42
Ioanni,

i do write the following for me to understand.

i have the var TEMPIR which gives a value for example of 14450.

Then i do have an other VAR which is temperature.

If i devide
temperature = TEMPIR / 50 we get
289.

then for getting the temp value we do
temperature = temperature - 273 , which gives to us 16. But we do not get the remainder value.

The remainder value is
Remainder = TEMPIR*2//100, which the result is 9 for our example of 14450.

Now i have an LCD that requires a CS value to be added in a command.

9110

Thats why i gosub to find and calculate the CS value of the overal command.

I think that i need somehow to calculate and convert the variable to string, ourside from the HSEROUT command.

Apparently the DEC5 didnt work. :(

Ioannis
- 18th December 2021, 20:56
The msb and lsb in your display string what are exactly? Ascii values or binary?

And being msb and lsb, I understand that these two construct a word value. For what purpose? Your display for example, can display on screen a binary word value of %0000000000000001 as plain 1?

Ioannis

astanapane
- 18th December 2021, 21:07
According to the manual of the display and the VISI GENIE OS.

The following is an example.

9111

I'm missing something, because right now as the code is, returning from the Checksum calculation, the HSEROUT command is set right. But i do get HEX result. Right?

Ioannis
- 18th December 2021, 21:16
The number is just the same either hex, binary or decimal. 128 is the same as %10000000 or $80. You show it in different way.

The trackbar object, what exactly is?

Ioannis

astanapane
- 18th December 2021, 21:22
Trackbar is only an object ID in VISI GENIE OS for the Display like the following.

9113

in our case we do use the LEDDIGITS which the OBJECT ID is $0F

9114

Ioannis
- 18th December 2021, 21:39
OK, I see.

So, if you want to move the trackbar to position $28 you will use



HserOut [$01,$05,$00,$00,$28,$2C]


and the slider will goto position $28.

But I guess you have to set beforehand the two ends of the trackbar? I mean the zero can be 100 and the maximum position 200, or whatever.

Can you try and see if you can move the trackbar just by sending straight in values? and the CRC computed by hand.

Then you may do more complicated things.

Ioannis

astanapane
- 18th December 2021, 21:54
in my case i do not use the trackbar, but the LED digits as shown below.

9115

In the software 4D SYstems they have, you can set manually a number for example 167, and will show you the command as shown in the SET DIGIT VALUE:

9116

I have tried to give manually a constant number and it worked!

what i did is:

i set a new var mTEMP ' for manually hex number and
a new var mTEMPIR ' for manually hex number as well.

In our case the number 167 for:



mTEMP = $00
mTEMPIR = $a7

then i did the CS calculation and return to the HSEROUT command.



IRCS=0
IRCS= $01^$0F^$00^mTEMP
IRCS = IRCS ^ mTEMPIR

I placed it with:


HSEROUT [$01,$0F,$00,mTEMP,mTEMPIR,IRCS)

then i got the right result on the display.

The problem is that when i use the variables i cannot get the right values.

richard
- 19th December 2021, 00:46
i assume the real question in this jumble is how do i sent a word var as a binary number msb first using hserout

Temp var word
Temp=167


HSEROUT [$01,$0F,$00,Temp.highbyte,Temp.lowbyte,IRCS)

astanapane
- 19th December 2021, 08:16
Richard!!!!

it really worked!!!


'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''
' VAR for IR to LCD '
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''
IRCS var byte ' this is the checksum for the IR required in external display command
TEMP var word ' this is the word variable for TEMP
temperature var word ' for result and output to lcd
TEMPIR var word ' set a variable tempir
Remainder var word ' Get the remainder = tempir//50

'------------------------------------------------------------------------------*
' Measure IR object temp sent to uLCD *
'------------------------------------------------------------------------------*
object:

reg = $07 ' based on the datasheet $07 is the object's temp
addr = %10110100 ' $B4 binary value: %10110100
i2cwrite SDA, scl, addr ' send write command, shift the address B4, 8 bits where LSB is W = 0
i2cwrite sda, scl, reg ' register is $07

addr = %10110101 ' $B5 Binary value: %10110101
i2cwrite sda, scl, addr ' sends read command, shift the address B5, 8 bits where LSB is R = 1, clock idles low
i2cread SDA, SCL,addr,reg,[temp.lowbyte,temp.highbyte] ' reg = $07

tempir = (temp.highbyte << 8) + temp.lowbyte

temperature = tempir/50 ' based on the manual we need to divide by 50 or 0.02
temperature = temperature - 273 ' subtract 273 for Degree in C,actually is 273,15
remainder = (tempir*2)//100 ' multiply x 2 and get the remainder //100

pause 100
gosub display
return

'------------------------------------------------------------------------------*
' IR Display 1 the parameters *
'------------------------------------------------------------------------------*
display: ' IR TEMP
hserout2 [$73,$00,$02,$12,$00,$ff,"IR TEMP:",00]
Hserin2 timeout,error,[wait(6)]
hserout2 [$73,$08,$02,$12,$F8,$00,dec2 temperature,".",dec2 remainder,"*C",00] 'this one works on display 1 which doesnt require CS
Hserin2 timeout,error,[wait(6)]


gosub checksum2
HSEROUT [$01,$0F,$00,temperature.highbyte,temperature.lowby te,IRCS) ' this one works.
Hserin timeout,error,[wait(6)]
return

'------------------------------------------------------------------------------|
' CHECKSUM IR |
'------------------------------------------------------------------------------|
checksum2:
IRCS = 0
IRCS = $01 ^ $0F ^ $00 ^ temperature
'IRCS = IRCS ^ remainder ' commended this as i need to figure out how to import it in the HSEROUT command.
return

Now i'm trying to figure out how to add the remainder in the command.

richard
- 19th December 2021, 09:05
Now i'm trying to figure out how to add the remainder in the command.

i hope this is not a medical diagnostic device
your temperature calculation is not accurate and the remainder calculation is mathematically incorrect



temperature = tempir/50 ' based on the manual we need to divide by 50 or 0.02
temperature = temperature - 273 ' subtract 273 for Degree in C,actually is 273,15

yields the temp in deg C to about 1 deg of resolution with an error of +- 1 degree


remainder = (tempir*2)//100 ' multiply x 2 and get the remainder //100


calculated the 100 modulus of the temp in deg kelvin

adding them together is nonsense , trying to display a two decimal point result is from any of these results is just not right

9117



wtf tempir = (temp.highbyte << 8) + temp.lowbyte ;just Nooooo! its the hardest most convoluted way i have ever encountered to go
tempir = temp which serves no purpose anyway




don't like this either, it pisses away too much resolution hence its not particularly accurate
temperature = tempir/50 ' based on the manual we need to divide by 50 or 0.02
temperature = temperature - 273 ' subtract 273 for Degree in C,actually is 273,15
remainder = (tempir*2)//100 ' multiply x 2 and get the remainder //100


;this is good although it could be even more accurate [temperature = temp*2 - 27315 ; temp x 2 - 273.15*100 ] >==>temperature*100] if the raw value won't exceed 32768


temperature = (temp - 13657)<<1 ; (temp-[273.15*50]) x 2 <==> temperature*100; is good




i make the assumption temperature * 100 is the value required by the slider display


tempir and remainder are not needed





display like this



'------------------------------------------------------------------------------*' IR Display 1 the parameters *
'------------------------------------------------------------------------------*
display: ' IR TEMP
hserout2 [$73,$00,$02,$12,$00,$ff,"IR TEMP:",00]
Hserin2 timeout,error,[wait(6)]
hserout2 [$73,$08,$02,$12,$F8,$00,dec2 temperature/100,".",dec2 temperature//100,"*C",00]
Hserin2 timeout,error,[wait(6)]



gosub checksum2
hserout [$01,$0F,$00,temperature.highbyte,temperature.lowby te,IRCS]
Hserin timeout,error,[wait(6)]
return


'------------------------------------------------------------------------------|
' CHECKSUM IR |
'------------------------------------------------------------------------------|
checksum2:
IRCS = 0
IRCS = $01 ^ $0F ^ $00 ^ temperature.highbyte ^ temperature.lowbyte
return



then lets have a look at the i2c stuff , its not right either really


ps if negative temps are possible then additional code req

astanapane
- 19th December 2021, 09:48
Richard,

really thanks for your time.

I found this,if i remember correctly somewhere related to this specific sensor (https://www.waveshare.com/wiki/Infrared_Temperature_Sensor).


tempir = (temp.highbyte << 8) + temp.lowbyte

Then in the equation i have added the following


temperature = tempir/50 ' based on the manual we need to divide by 50 or 0.02
temperature = temperature - 273 ' subtract 273 for Degree in C,actually is 273,15

Your way is much more efficient and works just as expected. :) Im very happy.

Now what is wrong with the I2C command?

richard
- 19th December 2021, 10:27
I found this,if i remember correctly somewhere related to this specific sensor.


Code:
tempir = (temp.highbyte << 8) + temp.lowbyte


maybe but in conjunction with
i2cread SDA, SCL,addr,reg,[temp.lowbyte,temp.highbyte] ' reg = $07

its not useful in any way


Now what is wrong with the I2C command?

all this achieves is exactly nothing


reg = $07 ' based on the datasheet $07 is the object's temp


grave doubts about all of this it looks like some mishmash of a C code method where no read/write register command exists as it does in pbp
addr = %10110100 ' $B4 binary value: %10110100
i2cwrite SDA, scl, addr ' send write command, shift the address B4, 8 bits where LSB is W = 0
i2cwrite sda, scl, reg ' register is $07


i2cwrite sda, scl, addr,reg, [some data of some sort] ' register is $07 ;would be the normal way if you had any data to write


totally bogus in pbp bit 0 should always be 0
addr = %10110101 ' $B5 Binary value: %10110101


a form of torture to i2c chips with an incomplete transaction
i2cwrite sda, scl, addr ' sends read command, shift the address B5, 8 bits where LSB is R = 1, clock idles low




all that's needed
reg = $07
addr = %10110100
i2cread SDA, SCL,addr,reg,[temp.lowbyte,temp.highbyte] ' reg = $07 ;would be the normal pbp way

Ioannis
- 19th December 2021, 10:42
Richard,

Then in the equation i have added the following


temperature = tempir/50 ' based on the manual we need to divide by 50 or 0.02
temperature = temperature - 273 ' subtract 273 for Degree in C,actually is 273,15



Well, if that compiler could do floating, maybe it could be used. But in PBP integer math? I do not think so. You need what Richard did as a workaround.

Ioannis

astanapane
- 19th December 2021, 11:01
Richard,

now i got a bit comfused. If i only add the following, it doent work as expected



all that's needed
reg = $07
addr = %10110100
i2cread SDA, SCL,addr,reg,[temp.lowbyte,temp.highbyte] ' reg = $07 ;would be the normal pbp way

But if i add the write mode and I2Cwrite command it works.


reg = $07 ' this is the register for IR temp mode
addr= %10110100 ; this is the write mode

i2cwrite SDA, SCL, addr
i2cread SDA, SCL, addr, reg, [TEMP.lowbyte, TEMP.highbyte]

the following also works.



reg = $07 ' this is the register for IR temp mode
addr= %10110100 ; this is the write mode
i2cwrite SDA, SCL, addr

addr= %10110101 ; this is the read mode
i2cread SDA, SCL, addr, reg, [TEMP.lowbyte, TEMP.highbyte]

if i do not add the following line the code doesnt work.


i2cwrite SDA, SCL, addr

Shouldnt we write first and then read? ok i understand that we have nothing to write. But why it doent work if i do not add the i2cwrite line?

richard
- 19th December 2021, 12:48
Shouldnt we write first and then read? ok i understand that we have nothing to write. But why it doent work if i do not add the i2cwrite line?

which is precisely what the i2cread command does for you automatically. it should not ever be necessary to add a extra write , no i2c chip i have ever encountered has needed such treatment



i2cwrite SDA, SCL, addr

is an incomplete transaction. if your chip needs it then it is not a true i2c device or something else is occurring.
a logic analyzer would show what's really happening. its not normal and should be examined further to have any confidence
that the code is really viable in the long term


addr = %10110100

trying to set bit0 [the r/w bit] of a i2c address with pbp's i2c commands is not possible and will not have any effect
the code will set the r/w bit as needed

richard
- 19th December 2021, 12:58
it could be the chip is not really i2c and behaves differently

try this, at least its a nicer transaction
i2cwrite SDA, SCL, addr,[7]
i2cread SDA, SCL, addr,[TEMP.lowbyte, TEMP.highbyte]



looking at the wiki link you posted, this would do exactly what the smbus timing diagram describes as a proceedure

PEC var byte
i2cread SDA, SCL,addr,reg,[temp.lowbyte,temp.highbyte,PEC] ' reg = $07 ;would be the normal pbp way

worth trying

astanapane
- 19th December 2021, 13:12
Hi Richard,

sure i'll try that, and i will try to figure out what is going on with a logic analyzer.

I have a saleae logic 8.

Will try that later today. Many thanks for your time once again.

richard
- 19th December 2021, 13:19
If there is only one MLX90614 sensor, the 7-bits address is 0x00 by default.
according to wiki addr =0 where did you get B4 from ?

Ioannis
- 19th December 2021, 13:25
If the chip is the MAX30102, on page 16 seems that reading needs first a write.

Ioannis

astanapane
- 19th December 2021, 13:27
wait a sec,

im reading the manual again from the SENSOR

https://www.waveshare.com/w/upload/e/e4/MLX90614-EN.pdf

9119

astanapane
- 19th December 2021, 13:28
If the chip is the MAX30102, on page 16 seems that reading needs first a write.

Ioannis

it is an IR MLX90614

astanapane
- 19th December 2021, 21:45
Applying the 0x00 is not working.

When i add back the B4 or B5 for write or read mode correspondingly, everything is in a working order again. :D

richard
- 19th December 2021, 22:27
Its hard to work with crappy information


9120

i2cread SDA, SCL,$b4,7,[temp.lowbyte,temp.highbyte,PEC] will do exactly that


i just realized that what code you posted is in fact a snippet .
addr and reg are never defined , osc is unknown ,i2c defines unknown, pin settings and i2c pull ups ...........

could be another waste of time

astanapane
- 20th December 2021, 09:23
Richard,

i have thanked you so many times for your effort and help.

I think i have attached in the code most of the information required.

You have helped me in the first major issue i had with the right values and the command needed inside the HSEROUT.

Then we moved to I2C command. I think there i have shared the reg and addr values. For the SCL and SDA i dont think that is necessary at all to post which port is or not.

Anyway, now the code is working just fine and i need once again to thank you all for your help and time.

Once again Richard. Life is simpler and shorter than we all think. Smile because you have the knowledge in this field to help people. :)

richard
- 20th December 2021, 09:34
out of curiosity i downloaded the real data sheet and discovered quite a few things
9125

1 the bus speed is 100khz
2 the datasheet depicts an abnormally long repeated start signal on a read transaction [no specs but]
3 the bus needs a SMBus Request signal before a read/write transaction
4 the genuine article has addr 0 not 0xb4

looking at ebay banggood aliexpress etc yields a 5 to 1 price range from $10 to nearly $60 us
most venders spruking a multitude of part numbers in the listing, you would wonder what you are buying
i suspect clones fakes and lookalikes abound

a real one from e14 or rs is $40ish au , a bit much for a play trinket for me
so i don't think i can take it much further

richard
- 20th December 2021, 09:42
I think i have attached in the code most of the information required.

Then we moved to I2C command. I think there i have shared the reg and addr values. For the SCL and SDA i dont think that is necessary at all to post which port is or not.

wrong on all counts

the i2c defines and osc speed can be crucial to i2c bus problems
pin and port settings can also play a vital role
the type of vars defined for reg and addr are also important ,for instance if reg is a word var then all bets are off

sorry i tried

astanapane
- 20th December 2021, 10:22
Richard,

your help is always appreciated. You were right once again.

I had the


reg var Word

I think i've seen it as a comment somewhere here in the forum.

Now i have changed the code and used byte insted of word for the reg and used only the code line you suggested and taaaadaaa, it worked.

Apart from that......

i think i have the original from melexis the IR module as it cost here in Europe around 25 Euros.

The link of the Datasheet is the following.

https://www.melexis.com/en/documents/documentation/datasheets/datasheet-mlx90614

and this is the part of the datasheet shown the revision and the date.

9126

richard
- 20th December 2021, 21:32
Its hard to work with crappy information
could be another waste of time

and it was


I had the
reg var Word
I think i've seen it as a comment somewhere here in the forum.


a classic case of monkey see monkey do programming error hidden away by use of snippets
days wasted, hundreds of posts to solve an elementary error.

i would not be surprised to find there is still one more major issue for the i2c settings still not addressed
for this precious secret code . i hope this is not a medical diagnostic device

astanapane
- 20th December 2021, 21:52
------------------------

is there a point to answer to such a negative behavior and bad attitute? I think you have a problem man. Get a girl.

richard
- 20th December 2021, 22:59
is there a point to answer to such a negative behavior and bad attitute

i don't mind your attitude so much, its just a wonder to me that anyone could come to this forum looking for free programming help.
help for a problem they cannot solve themselves , then refuse or begrudgingly supply the detail identified as potentially problematic.
you expect solutions from code snippets that only bring a problem to light not actually cause it.
solutions are offered , pitfalls exposed even though the necessary info had to be painstakingly extracted over numerous posts.
then only to be met with anger and indignation , you have to laugh

but there is a point. snippets have been shown to be a waste of time over and over again

astanapane
- 21st December 2021, 06:19
fix your inside first.

You share a proof data document to me from 2009, and you are trying to tell me that i have a fake module.

You still do not listen. Forget about me and my monkey programming. Forget everything! You may be a good programmer, but a very very bad teacher or someone that could help in a forum.

Check the answers from DT in the past. Check and learn from his kidness and for his possitive behaviour. LEARN man LEARN.

YOU NEED HELP MAN anyway.....from medical side. I cannot help you from here, but still, listen to me at least and ask for a help soon.

Hope you will find your way. You need help.

I will be here if you need to talk to someone, but medically i cannot help you.

Thanks once again for all the help and time you spent.

richard
- 21st December 2021, 07:39
let be clear here the address doubt set in from the very link you submitted
https://www.waveshare.com/wiki/Infrared_Temperature_Sensor


you are trying to tell me that i have a fake module.
i never said that at all, but yes i had picked up an old datasheet , i let your address go unchallenged so what's the issue here, it needed clarification.

all said and done since you are so reticent to post your code i was left with seeking a reason why the device did not respond as expected
to a seeming valid i2c transaction , a quick look on the web led to reasonable doubt that the device was as described.
i make no apology for that . i enjoy a challenge and was prepared to investigate adding a smbus request signal if warranted
it would have been interesting.

proof conclusive snippets are a waste of time , my case rests

oh yeah

a very very bad teacher or someone that could help in a forum.

its hard to soar with eagles when you are working with turkeys

i'm not going to spend a pile of time writing nice flowery prose and go about smoothing egos on a technical forum for simple issues

good luck with your endeavors i'm done

Ioannis
- 21st December 2021, 08:18
No need for flames here please.

We are on this forum to help and not hurt each other.

Especially with the season coming...

Ioannis

richard
- 21st December 2021, 09:05
i have had three or four people say i'm not a good teacher,
i'm not surprised since i never have been or ever aspired to be one

so what do think of my new signature ?

Warning I'm not a teacher , one on one Tuition with flowery prose like a gushing embroilment is not my style

astanapane
- 21st December 2021, 11:55
Richard,

i may need to apologize for my behaviour as well. I do not expect that from you.

Do what you know better to do, in this particular field. Everyone has its bad and good days. We are all in the same boat.

You never know one day, i may be some how useful for you.....

Take care and try to smile.